0

I would like to use a yml variables file, rather than an ARM parameters file, so that I can use a single variable file for multiple bicep deployment tasks and to use the variables in other pipeline tasks without duplication, but am having trouble with the syntax. Below is what I have. It seems to not see it as valid syntax. I get the following error: There was an error while overriding 'tags' parameter because of 'SyntaxError: Unexpected end of JSON input', make sure it follows JavaScript Object Notation (JSON)

What is the correct syntax or is there a better way that meets the criteria?

# vars.yml contents
rsgName: "rsg1"
location: "westus"
tags: |
  {
  "tag1": "tagA",
  "tag2": "tagB"
  }

# deploy.yml contents
- task: AzureResourceManagerTemplateDeployment@3
    inputs:
      deploymentScope: 'Subscription'
      azureResourceManagerConnection: ${{ parameters.azureServiceConnection }}
      subscriptionId: ${{ variables.subId }}
      templateLocation: 'Linked artifact'
      csmFile: ./template.bicep
      overrideParameters: >
        -rsgName ${{ variables.rsgName }}
        -location ${{ variables.location }}
        -tags ${{ variables.tags }}
      deploymentMode: 'Validation'

# template.bicep contents
param rsgName string
param location string

targetScope = 'subscription'

resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
  name: rsgName
  location: location
  tags: tags
Philosophene
  • 80
  • 1
  • 7

1 Answers1

0

As per the task doc, it supports multiple parameters overwrite on the task.

If you use classic UI editor of the task, click ... , it could be more clear.

enter image description here

The error should be caused by the incorrect format on the tag definition on your vars.yml .

  1. Remove extra , behind "tag2": "tagB" to fix the json format for a check.
  2. Or you can try to use simple tag content for a check.
wade zhou - MSFT
  • 1,397
  • 1
  • 3
  • 6
  • I have removed the comma from the example, which didn't exist in the original code. If I remove the tags entirely, I get `The 'location' property must be specified` – Philosophene Dec 30 '22 at 16:54
  • Thanks @Philosophene. To narrow down the issue, please try to export the value of `${{ variables.location }}`, does it have correct value? In addition, please try to replace real value for `location` on bicep content for a check, will the error disappear? – wade zhou - MSFT Jan 02 '23 at 07:07
  • The variables show up in the pipeline. This issue is getting them to work in bicep. – Philosophene Jan 10 '23 at 17:18