阿萨夫,
这是不可能的,但假设您想在后续的 VSTS 任务中使用您的变量,以下是实现它的步骤。
最后,在您的主 ARM 模板文件中,输出您的变量,如下所示:
"outputs": {
"vhdStorageName": {
"type": "string",
"value": "[variables('vhdStorageName')]"
}
}
完成部署任务后,通过执行以下 PowerShell 脚本在VSTS 任务上下文中设置变量:
param ([string] $resourceGroupName)
#get the most recent deployment for the resource group
$lastRgDeployment = (Get-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName | Sort Timestamp -Descending | Select -First 1)
if(!$lastRgDeployment)
{
throw "Resource Group Deployment could not be found for '$resourceGroupName'."
}
$deploymentOutputParameters = $lastRgDeployment.Outputs
if(!$deploymentOutputParameters)
{
throw "No output parameters could be found for the last deployment of '$resourceGroupName'."
}
$deploymentOutputParameters.Keys | % { Write-Host ("##vso[task.setvariable variable="+$_+";]"+$deploymentOutputParameters[$_].Value) }
对于此脚本,您需要提供将在其中进行部署的 Azure 资源组名称。该脚本获取资源组中的最后一个部署,并将每个输出设置为 VSTS 任务上下文中的变量。
访问您的变量并将其用作任何其他 VSTS 变量的参数:
-myparameter $(vhdStorageName)