1

In an Azure Resource Group Deployment task, can I override a parameter that has a space in its name?

I followed this guide to create an Azure resource group deployment project. In that project I'm able to create parameters with spaces in the name and successfully deploy it via Visual Studio.

azuredeploy.json

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "My easy to read parameter": {
      "type": "string",
      "defaultValue": "hello world"
    }
  },
  "resources": [
    {
      "name": "[parameters('My easy to read parameter')]",
      "type": "Microsoft.Storage/storageAccounts",
      "location": "[resourceGroup().location]",
      "apiVersion": "2016-01-01",
      "sku": {
        "name": "[parameters('StorageType')]"
      },
      "dependsOn": [],
      "tags": {
        "displayName": "MyTag"
      },
      "kind": "Storage"
    }
  ]
}

It appears I can override parameters using this: overrideParameters: '-myNotSoEasyToReadParameter integration-webfarm' source.

How do I do that on a parameter w/ spaces?

overrideParameters: '-My easy to read parameter integration-webfarm'

2
  • Can you share the log of the Azure Resource Group Deployment task?So I can judge which parameters are used in the API according your service .The parameters set in override template parameters need to be used in the API. If they are not used, it is meaningless to override them. Commented Oct 31, 2019 at 11:12
  • Hi @HughLin-MSFT - thanks for the reply. I haven't tried running it as I know I don't have the correct syntax. I am confident I'm using the parameter. I've updated my question. Commented Oct 31, 2019 at 18:58

1 Answer 1

4

The answer is Yes and No.

The Yes means this special parameter name My easy to read parameter can be override. And No means the approach you are using is not correct.

Firstly, hello world is a invalid value. Since what you defined it is a Microsoft.Storage/storageAccounts type, it does not allow you to use the characters other than lowercase letters and numbers, including spaces.

To achieve overriding the parameter name My easy to read parameter, you can not directly override it in the task configuration:

enter image description here

The name with spaces could not be recognized by the task. Because of the spaces, this task could not treat this special name as one completed string and will try to parse it. Then you would received the error like follow show:

enter image description here

Even not work by using double quotes around it.


The correct and succeed overriding method is using Override Parameter json file.

Create a new parameter json file, then specified the parameter name and value which you want to be override.

For example:

(1). This is my template json file which parameter name is My easy to read parameter and value is merlinliang:

enter image description here

(2). Now, create a another parameter json file. Specified a new value merlinoverride in it:

enter image description here

(3). In ARM deploy task configuration, configure like this:

enter image description here

You can see the name was override successfully:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

I guess I couldn’t pass parameters from my pipeline down then 😢 if the only option is a params file
@spottedmahn. Any limitation? Because only there 2 method can override the parameter in this task. One is directly specify in the input box under Override template parameters by using -{name} {new value}. And another one is using parameter file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.