【发布时间】:2017-06-14 15:20:58
【问题描述】:
当似乎无法表达参数或参数文件被成功解析时,如何在 VSTS azure powershell 构建步骤上执行“azure group deployment create”命令?
我在本地 powershell 中执行上述操作没有问题,但是在命令的 --parameter 定义部分时只得到一个错误,在默认构建代理的 VSTS 步骤中执行此操作时,其中 azure cli 是可访问的。
作为一个简单的示例,如何从默认构建代理上的构建步骤成功运行此股票教程部署?
azure group deployment create name ExampleDeployment resource-group ExampleGroup template-uri "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-storage-account-create/azuredeploy.json" --parameters "{\"storageAccountType\":{\"value\":\"Standard_GRS\"}}"
至关重要的是,这部分失败了:
--parameters "{\"storageAccountType\":{\"value\":\"Standard_GRS\"}}
在我的本地 powershell 中可以正常工作,表示为:
--parameters "{'storageAccountType':{'value':'Standard_GRS'}}"
如果尝试从 .json 文件中获取参数,该过程也会失败(尽管我需要内联工作,而不是外部参数文件)
在表达 --parameters 时,我尝试了双引号和单引号以及转义字符的所有变体。什么都不接受。
内联 -- 参数的典型错误是:
Parse error on line 1:
##[error]{'storageAccountType'
-^
Expecting 'STRING', '}', got 'undefined'
当尝试使用外部参数文件时:
Parse error on line 1:
##[error]@d:\a\1\s\params.jso
^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
我已经在构建代理上没有单独的 npm install -g azure-cli 的情况下尝试了上述所有方法。
非常感谢
【问题讨论】:
-
跟powershell有什么关系?为什么不在构建代理上使用 powershell?看例子,它应该是这样工作的:
"{\"storageAccountType\":{\"value\":\"Standard_GRS\"}}" -
嗨 - powershell 用于构建代理。该脚本被定义为 VSTS 构建步骤的一部分,复制到代理并在那里执行。解析失败的地方。
-
这不是powershell,这是azure cli,为什么不用powershell?
-
嗯。所以我现在在 Powershell VSTS 步骤中尝试了这个,而不是“Azure Powershell”VSTS 步骤。结果相同。尝试过: azure group deployment create --name ExampleDeployment --resource-group example --template-uri "raw.githubusercontent.com/Azure/azure-quickstart-templates/…" --parameters "{'storageAccountType':{'value':'Standard_GRS'}}" 解析错误第 1 行:{'storageAccountType' -^ 期待 'STRING','}',得到 'undefined'
-
还尝试了:azure group deployment create --name ExampleDeployment --resource-group example --template-uri "raw.githubusercontent.com/Azure/azure-quickstart-templates/…" --parameters "{\"storageAccountType\":{\" value\":\"Standard_GRS\"}}" 类似的解析错误
标签: azure azure-pipelines-build-task