I try to run the simple command of 'az version' that will be executed on a VM with the Run Command Script but I get this error: The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
But when I run this command from the VM, that I connect it with Remote Desktop Connection it works and I get the 'az version' with all the details. I also installed AZ Module in the VM.
What should I do in order to operate 'az' commands from the Run Command Script?
The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Based on the error message , looks like you don't have installed az module
to run the az version
cmdlet.
What should I do in order to operate 'az' commands from the Run Command Script?
You need to install Azure CLI to run the az cmdlet from the run command script from the portal.
You can use the below cmdlet will install the AzureCLI on windows machine with preinstalled Az modules.
$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi
post the installation of Azure CLI you can run the Az version cmdlet to check Az cli version.