Search code examples
azureazure-cli2

Microsoft example for installing Azure extension always gives error Expecting property name enclosed in double quotes: line 1 column 2 (char 1)


az vm extension set \

--resource-group QuickstartAnsible-rg
--vm-name QuickstartAnsible-vm
--name customScript
--publisher Microsoft.Azure.Extensions
--version 2.1
--settings '{"fileUris":["https://raw.githubusercontent.com/MicrosoftDocs/mslearn-ansible-control-machine/master/configure-ansible-centos.sh"]}'
--protected-settings '{"commandToExecute": "./configure-ansible-centos.sh"}'


Solution

  • I can reproduce this error when it runs on PowerShell ISE, but it works on the Bash environment on WSL.

    On PowerShell, you could enclose codes in double-quotes like this.

    az vm extension set --resource-group "nancytest" --vm-name "ubun-a" --name "customScript" --publisher "Microsoft.Azure.Extensions" --version 2.1 --settings "{'fileUris':['https://raw.githubusercontent.com/MicrosoftDocs/mslearn-ansible-control-machine/master/configure-ansible-centos.sh']}" --protected-settings "{'commandToExecute':'./configure-ansible-centos.sh'}"
    

    On PowerShell enter image description here

    On Bash enter image description here