1
votes

After Running this command on Azure Cli:

az vm extension set --publisher Microsoft.Compute --version 1.8 --name CustomScriptExtension --vm-name avmUat --resource-group argUat --settings '{"commandToExecute":"powershell.exe Install-WindowsFeature -Name Web-Server"}'

I get this error

Deployment failed. Correlation ID: 8d6972da-6d46-42e8-a053-f8e899348893. VM has reported a failure when processing extension 'CustomScriptExtension'. Error message: "Invalid handler configuration. Exiting. Error Message: Error converting value "{commandToExecute:powershell.exe Install-WindowsFeature -Name Web-Server}" to type 'Microsoft.WindowsAzure.GuestAgent.Plugins.CustomScriptHandler.PublicSettings'. Path 'runtimeSettings[0].handlerSettings.publicSettings', line 5, position 102.".

Edit: The result when I run it in powershell on Azure Cloud Shell: enter image description here

Bash and this is on bash (Gladly it worked) enter image description here

1
don't you need to add -command before the scriptblock of calling powershell.exe?Falco Alexander

1 Answers

0
votes

It seems that these commands do not work in the Azure CLI locally on the windows command prompt. You should run these on a bash environment.

With the same Azure CLI version. The same commands could work in Azure cloud Shell but not local Azure CLI in command prompt. I also tried running it on local Azure CLI 2.0.58, still failure.

Moreover, Here is the same Sample script, which is running in a bash environment.

Run this on my local command prompt. enter image description here

Run it on Azure Cloud Shell enter image description here