问题描述
有一个 ADO 任务来部署 arm 模板,并尝试使用我的哈希表中的动态标记(天蓝色图像库图像版本定义名称)来标记 Azure 资源(在下面的第二个任务中使用 arm 模板覆盖参数)。我部署 ARM 模板的第二个任务没有选择我设置的变量。 不确定我做错了什么以及这是否真的可能..
- task: AzurePowerShell@5
displayName: "Generate Tags"
inputs:
azureSubscription: **
ScriptType: 'Inlinescript'
Inline: |
$ImageVersion = (Get-AzgalleryImageVersion -ResourceGroupName $(sig_rg_name) -galleryName $(sig_name) -galleryImageDeFinitionName $(image_name)).name[-1]
$tags = @{'HostpoolName' = '$(hostpoolName)'; 'ImageVersion' = '$(ImageVersion)'} | ConvertTo-Json -Compress
Write-Host "##vso[task.setvariable variable=dynamictags]$tags"
## Also tried this construct with no luck:
## $json = [pscustomobject]@{ prop1 = "value1"; prop2 = "value2" } | ConvertTo-Json -Compress
## Write-Host "##vso[task.setvariable variable=MYVAR]$json "
- task: AzureResourceManagerTemplateDeployment@3
displayName: "Build Session Hosts "
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: **
subscriptionId: $(SubscriptionID)
action: 'Create Or Update Resource Group'
resourceGroupName: $(hostPoolRg)
location: $(AZlocation)
templateLocation: 'Linked artifact'
csmFile: 'ARM Templates/AddVirtualMachinestemplate.json'
csmParametersFile: 'ARM Templates/AddSessionHostTemplate.parameters_hp.json'
overrideParameters: '-hostpoolName $(hostPoolName) -hostpoolToken $(hostPoolRegKey) -tags $(dynamictags)'
deploymentMode: 'Incremental'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)