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"}'

1

There are 1 best solutions below

0
On BEST ANSWER

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