阿萨夫,
这是不可能的,但假设你想用你的变量在随后的VSTS的任务,这里有实现它的步骤。
在你的主臂的模板文件,在年底,output您变量就像下面:
"outputs": {
"vhdStorageName": {
"type": "string",
"value": "[variables('vhdStorageName')]"
}
}
部署任务后,通过执行这个PowerShell脚本设置你的变量在VSTS task方面:
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)
阿萨夫,你要能够产生一个ARM模板之外相同的字符串? 或 在您的方案中,您是否可以在ARM模板中生成字符串,将其作为输出返回,然后在PowerShell脚本或VSTS任务中使用它? –
要么。我的目标是在vsts任务中使用它。以相同的方式生成它或输出它。 –