0

I want to deploy the azure resources(ADF) and while deploying I need to override some DEV ARM template parameters and one of the parameters to deploy is of JSON OBJECT which I store its value in the pipeline Variable Group as below enter image description here

Actually the value looks like this {"minutes":[00],"hours":[5],"weekDays":["Monday","Tuesday","Wednesday","Thursday","Friday"]}

Since in azure DevOps pipeline, every Variable value that we fetch will be treated as a string type but my parameter for the ARM template need the value of Json type.

 - 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'

so whenever I try to run the pipeline it fails because the parameter LocalTesting_properties_typeProperties_recurrence_schedule is expecting the Json data but here I provided the string. I also tried the ConvertFrom-Json and "ConvertTo-Json" but not able to get the desired output.

Can you pls help me here?

1 Answers1

0

Try with jq.

You first parse it $scheduleJson= jq --null-input '$(Trigger_Schedule)' and then pass it as parameter.

 - task: AzurePowerShell@5
      displayName: Deploy ADF
      inputs:
        azureSubscription: '$(azureSubscription)'
        ScriptType: 'InlineScript'
        Inline: 
          $scheduleJson= jq --null-input '$(Trigger_Schedule)'
          New-AzResourceGroupDeployment `
             -ResourceGroupName "$(DeploymentResourceGroupName)" `
             -TemplateParameterFile "$(System.DefaultWorkingDirectory)/$(SourceDataFactoryName)/ARMTemplateParametersForFactory.json" `
             -TemplateFile "$(System.DefaultWorkingDirectory)/$(SourceDataFactoryName)/ARMTemplateForFactory.json" `
             -factoryName "$(DeployDataFactoryName)" `
             -LocalTesting_properties_typeProperties_recurrence_schedule $scheduleJson`
             #<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'
Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107