I want to run a script using Azure CLI command.
I am using following command to do it.
Command to execute:-
az vm extension set --resource-group rg1 --vm-name test --name CustomScript --publisher Microsoft.Azure.Extensions --version 2.0 --protected-settings '{"fileUris": ["https://test.blob.core.windows.net/testcontainer/test.sh?st=2018-05-28T19%3A56%3A00Z&se=2018-05-30T19%3A56%3A00Z&sp=r&sv=2017-04-17&sr=b&sig=LsAmSVWmggcBYXs7XwUhdA16HfSChi6%2FvH0vqjZMS%2F1YM%3D"], "commandToExecute": "bash test.sh 1 2 3"}'
I want to use like below to pass as variables in the command and am getting the following error
SCRIPT_LOCATION="https://test.blob.core.windows.net/testcontainer/test.sh?st=2018-05-28T19%3A56%3A00Z&se=2018-05-30T19%3A56%3A00Z&sp=r&sv=2017-04-17&sr=b&sig=LsAmSVWmggcBYXs7XwUhdA16HfSChi6%2FvH0vqjZMS%2F1YM%3D" SCRIPT_NAME="test.sh" PARAM1="test1" PARAM2="test2" PARAM3="test3"
Command to execute:-
az vm extension set --resource-group rg1 --vm-name test --name CustomScript --publisher Microsoft.Azure.Extensions --version 2.0 --protected-settings '{"fileUris": [$SCRIPT_LOCATION], "commandToExecute": "bash $SCRIPT_NAME $PARAM1 $PARAM2 $PARAM3"}'
Error:-
Deployment failed. Correlation ID: 72859669-9cdf-4bb0-9aac-1a6af52c7e1c. VM has reported a failure when processing extension 'CustomScript'. Error message: "Enable failed: failed to get configuration: json validation error: invalid protected settings JSON: fileUris.0: Does not match format 'uri'".