我想部署azure资源(ADF),在部署时需要覆盖一些DEV ARM模板参数,其中一个要部署的参数是JSON OBJECT,我将其值存储在管道变量组中,如下所示x1c 0d1x
实际上,值看起来像这样{"minutes":[00],"hours":[5],"weekDays":["Monday","Tuesday","Wednesday","Thursday","Friday"]}
因为在azure DevOps pipeline中,我们获取的每个Variable值都会被视为string类型,但我的ARM模板参数需要Json类型的值。
- task: AzurePowerShell@5
displayName: Deploy ADF
inputs:
azureSubscription: '$(azureSubscription)'
ScriptType: 'InlineScript'
Inline:
New-AzResourceGroupDeployment `
-ResourceGroupName "$(DeploymentResourceGroupName)" `
-TemplateParameterFile "$(System.DefaultWorkingDirectory)/$(SourceDataFactoryName)/ARMTemplateParametersForFactory.json" `
-TemplateFile "$(System.DefaultWorkingDirectory)/$(SourceDataFactoryName)/ARMTemplateForFactory.json" `
-factoryName "$(DeployDataFactoryName)" `
-LocalTesting_properties_typeProperties_recurrence_schedule $Trigger_Schedue `
#<parameter-overridden> : <value-to-be-overridden> there are parameters in arm template and overridden by key vault secrets `
#<parameter-overridden> : <value-to-be-overridden> (add any other parameter overrides as needed) `
-Mode "Incremental"
azurePowerShellVersion: 'LatestVersion'
字符串
因此,每当我尝试运行管道时,它都会失败,因为参数LocalTesting_properties_typeProperties_recurrence_schedule需要Json数据,但这里我提供了字符串。我还尝试了ConvertFrom-Json和“ConvertTo-Json”,但无法获得所需的输出。
你能帮我一下吗?
1条答案
按热度按时间3vpjnl9f1#
用
jq
试试。首先解析它
$scheduleJson= jq --null-input '$(Trigger_Schedule)'
,然后将其作为参数传递。字符串