使用 azure devops ci/cd 管道中的 azure cli
在azure虚拟网络中,创建了一个新的路由表,现在尝试创建一个路由
- task: AzureCLI@2
displayName: 'Route'
inputs:
azureSubscription: subscription
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
az network route-table route create `
--resource-group myrg `
--route-table-name test `
--name vnetroute `
--next-hop-type VirtualAppliance `
--address-prefix 0.0.0.0/0 `
--next-hop-ip-address 0.0.0.0
并收到此错误-
At D:\a\_temp\azureclitaskscript1712679912359_inlinescript.ps1:3 char:3
+ --route-table-name test `
+ ~
Missing expression after unary operator '--'.
At D:\a\_temp\azureclitaskscript1712679912359_inlinescript.ps1:3 char:3
+ --route-table-name test `
+ ~~~~~~~~~~~~~~~~
Unexpected token 'route-table-name' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingExpressionAfterOperator
有人可以帮忙吗?
相同的 Azure CLI 命令在我的管道和本地 PowerShell 中工作。此外,如果像下面的脚本一样缺少换行符
`
,我只能重现该问题。
# "--resource-group myrg" before "--route-table-name test" missing line breaker `
az network route-table route create `
--resource-group myrg
--route-table-name test `
--name vnetroute `
--next-hop-type VirtualAppliance `
--address-prefix 0.0.0.0/0 `
--next-hop-ip-address 0.0.0.0
请仔细检查您的内联脚本,或者您是否共享了 issue-reproducible YAML 内容。您可能从一个分支共享 YAML 文件中的工作脚本,而您的管道引用了另一个分支的 YAML 定义,而错误的脚本位于该分支。