0
votes

I use the ARM template deployment task in my release pipeline. The task has a parameter called Location.

In my parameters.json file, I also have a parameter called Location. How could I change this file so that it reads the value set on the task itself ?

Currently the value is read from a variable group's variable coming from azure keyvault. But I think it's overkill to have this location parameter coming from the vault.

See

2
You can use the --overrideParameters argument to override a parameter value that is specified in the JSON file. Did you try this?mm8
i didn't know about this indeed. But I'm using a tokenizer to replace parameters and it works just fine. My question was related to how getting the value from the task parameters; See pictureSam
Hi @Sam.Is there any update for this issue? If the answers could give you some help, you may consider accepting it .Just a reminder of this.Kevin Lu-MSFT

2 Answers

0
votes

Based on my test, I notice that the value in xxx.parameters.json couldn't read the value of the variable in pipeline.

For example:

I set the variable(test : abc) in Pipeline variables. Then I use it in the xxx.parameters.json file. When the Resource group creates, the vaiable doesn't be read in the resource group.

The parameters.json sample:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
      "adminUsername": {
            "value": "test"
        },
       "location": {
           "value": "$(test)"

       }

    }
  }

enter image description here

From the result, it seems that the location value couldn't be automatic used in the json file.

You may need to use the tokenizer task to manually override the specific value in the json file. Then the value could be used in the resource group.

Or you could directly use the Override template parameters in the ARM Template task.

enter image description here

Hope this could help.

0
votes

Location*:

For Resource Group deployment scope: Location for deploying the resource group. If the resource group already exists in the subscription, then this value will be ignored. For other deployment scopes: Location for storing the deployment metadata.

https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/AzureResourceManagerTemplateDeploymentV3

Given this information, you can set the location of the resource group via the task, and use this for all of your resources as well. If you want your resources to be in a different location than your resource group, you will not be able to leverage the task parameter.

This is how it looks like in ARM:

    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }

https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/resource-location?tabs=azure-powershell#use-location-parameter