I'm trying to run a script using either PowerShell AZ or AZ Cli. The script is located in an Azure Blob Storage, it is supposed to download a zip file on the server, unzip it and launch the installation. The URL if the Zip file is provided as parameter of the script (this url contains a SAS token).
Everything works perfectly fine when using the "Run Command" blade of Azure Web Portal.
I now want to industrialize the actions a little bit better with a script that creates a SAS token and pass the parameters directly to initiate run commands.
I initially tried with Set-AzVMRunCommand, but had an issue to pass parameters: whatever the syntax used, the parameter value is never passed. The best I could achieve was to pass -Parameter @{name="URL";value="$ZipURI"} where I can see the "URL" parameter with Get-AzVMRunCommand but the value seems to never arrive.
I then tried with az cli as it seemed to solve the problem for many, but it does not look like az cli understands the --script-uri when it contains a SAS token, as I get errors like that:
'se' is not recognized as an internal or external command, operable program or batch file.
Edit: Many thanks for your answers. Here are the full commands, I hope that helps, do not hesitate to ask me for more details.
Set-AzVMRunCommand -ResourceGroupName $ResourceGroupName -VMName $VirtualMachineName -RunCommandName "Deploy" -SourceScriptUri $SourceScriptURI -Location $Location -Parameter $Parameters
$SourceScriptURI is an url generated with the script name and SAS token $Parameters = @{name="URL";value="$ZipURI"}
Command is similar in AZ Cli
az vm run-command create --run-command-name "TaniumInstall" --vm-name $VirtualMachineName --resource-group $ResourceGroupName --script-uri $SourceScriptURI -protected-parameters URL=$ZipURI
Has anyone ever achieved this?
Thanks.