Azure devops 使用Azure DevOps部署ARM:找不到任何与模板文件模式匹配的文件

Azure devops 使用Azure DevOps部署ARM:找不到任何与模板文件模式匹配的文件,azure-devops,azure-resource-manager,Azure Devops,Azure Resource Manager,我正在尝试使用Azure DevOps部署ARM。 Git repo的路径是“ARMTemplates\CreateSQLServerARM\azuredeploy.json” 然而,我得到了错误。有什么不对劲吗 错误: Checking if the following resource group exists: KensTestRG. Resource group exists: true. Creating deployment parameters. ##[error]Erro

我正在尝试使用Azure DevOps部署ARM。 Git repo的路径是“ARMTemplates\CreateSQLServerARM\azuredeploy.json” 然而,我得到了错误。有什么不对劲吗

错误:

 Checking if the following resource group exists: KensTestRG.
 Resource group exists: true.
 Creating deployment parameters.
 ##[error]Error: Could not find any file matching the template file pattern
 Finishing: AzureResourceGroupDeployment
代码: #起动器管道

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
-     task: AzureResourceGroupDeployment@2
  inputs:
    deploymentScope: 'Resource Group'
    ConnectedServiceName: 'AzureRmPipeline-conn'
    subscriptionId: '1111753a-501e-4e46-9aff-6120ed562222'
    action: 'Create Or Update Resource Group'
    resourceGroupName: 'KensTestRG'
    location: 'North Europe'
    templateLocation: 'Linked artifact'
    csmFile: 'ARMTemplates\CreateSQLServerARM\azuredeploy.json'
    deploymentMode: 'Incremental'
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
  • 脚本:| echo添加其他任务以构建、测试和部署项目。 回音见 displayName:“运行多行脚本”

该错误表示找不到参数csmFile中指定的azuredeploy.json文件

当azure agent构建管道时,repo源代码将克隆到代理计算机上的默认工作文件夹(
$(System.DefaultWorkingDirectory)
ie.
c:\agent\u work\1\s
)中。如果您的回购协议如下所示:

然后,代理计算机中的文件夹结构如下所示

s |
   - Deploymentfiles
     |
     - StorageAccount 
       |
       - **.json
   - VirtualNetwork
     |
      ...
   - readme.md
csmFile的路径应该是
csmFile:'Deploymentfiles\StorageAccount\azuredeploy.json'

但是,如果您不确定文件夹结构,也可以使用通配符,如下面的示例所示

csmFile:'**\azuredeploy.json'

csmFile:'$(System.DefaultWorkingDirectory)\**\azuredeploy.json'

更新

如果管道以ubuntu代理为目标。“/”应在
csmFile
字段的文件路径中使用。(“\”表示windows系统中的文件路径)

csmFile:'ARMTemplates/CreateSQLServerARM/azuredeploy.json'

csmFile:'**/azuredeploy.json'


csmFile:'$(System.DefaultWorkingDirectory)/**/azuredeploy.json'

这些对我不起作用:csmFile:'**\azuredeploy.json'csmFile:'$(System.DefaultWorkingDirectory)**\azuredeploy.json'csmFile:'\ARMTemplates\CreateSQLServerARM\azuredeploy.json'Hi@Kenny\I我刚刚注意到你在使用的是agent
ubuntu最新版本
,对于linux系统,请将文件路径中的“\”替换为“/”。请查看上面的更新。替换文件中的“\”即可正常工作。谢谢