3

I am using Azure CLI 2.0 on a windows machine and I am trying to create a Docker VM using this Microsoft documentation:

az group deployment create --resource-group myResourceGroup \
  --parameters '{"newStorageAccountName": {"value": "mystorageaccount"},
    "adminUsername": {"value": "azureuser"},
    "adminPassword": {"value": "P@ssw0rd!"},
    "dnsNameForPublicIP": {"value": "mypublicdns"}}' \
--template-uri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/docker-simple-on-ubuntu/azuredeploy.json

Putting everything in one line results in an "unrecognized arguments" error. Replacing the parameter single quotes by double quotes results in an "Expecting property name enclosed in double quotes" error and removing the parameters option gives an expected "Deployment template validation failed" error. What is the correct way to provide the parameter value?

sschmeck
  • 7,233
  • 4
  • 40
  • 67
Jeroen Heier
  • 3,520
  • 15
  • 31
  • 32

4 Answers4

9

Please try this script:

az group deployment create --resource-group jason --parameters "{\"newStorageAccountName\": {\"value\": \"jasondisks321\"},\"adminUsername\": {\"value\": \"jason\"},\"adminPassword\": {\"value\": \"122130869@qq\"},\"dnsNameForPublicIP\": {\"value\": \"jasontest321\"}}" --template-uri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/docker-simple-on-ubuntu/azuredeploy.json

It works for me.

In cli 2.0, we can use --help to find the command help:

C:\windows\system32>az group deployment create --help

Examples
    Create a deployment from a remote template file.
        az group deployment create -g MyResourceGroup --template-uri
        https://myresource/azuredeploy.json --parameters @myparameters.json

    Create a deployment from a local template file and use parameter values in a string.
        az group deployment create -g MyResourceGroup --template-file azuredeploy.json --parameters
        "{\"location\": {\"value\": \"westus\"}}"
Jason Ye
  • 13,710
  • 2
  • 16
  • 25
  • After reading help command it was clear what i did wrong. There is an error in the first script: you need a starting and ending quote for the parameters property: --parameters " ....". – Jeroen Heier Mar 31 '17 at 05:28
2

You can add you parameters in the following format:

--parameters '{ "adminUsername": {"value":"username"}}'
Ehsan Zargar Ershadi
  • 24,115
  • 17
  • 65
  • 95
2

This is what i have tried with single quote('') instead of double quote ("") and it worked for me.

az group deployment create --name TempGroup --resource-group insightsrg --parameters '{\"actionGroupName\": {\"value\": \"jsonActionGroup\"},\"actionGroupShortName\": {\"value\": \"JAG\"}}' --template-file "C:\HM\ARM\policy\actiongroup\actiongroup.json"

Kindly find an attached screenshot for reference.

enter image description here

Sachin Kalia
  • 1,027
  • 14
  • 24
2

At time of writing, parameters can now simply be provided from file or inline as per the provided example from --help:

az group deployment create -g MyResourceGroup --template-file azuredeploy.json --parameters @params.json --parameters https://mysite/params.json --parameters MyValue=This MyArray=@array.json
Marc Stevenson
  • 1,090
  • 8
  • 9