Hi Team,
Could you please let me know whether we an run PowerShell scripts ,with az commands in runbook (automation ).
When i try to run, its showing as az commands not recognized
@fengzhou-msft please take a look
hi @nidiculageorge azure automation supporting python2, while azure cli is on python 3.x.
@yungezz is it possible to run powershell scripts with az commands in runbooks.When i try to run its showing as az command not found
Please see the attached screen shot

that's because azure cli isn't installed. hi @qwordy could you pls help to see is there way to install azure cli inside python2 runtime by pip?
@yungezz why are we using python 2 as its a powershell script that we are trying to run,these are the commands that we are trying to run
az vmss deallocate --resource-group aks-poc-seabnode --name aks-seabpocln-36792229-vmss
az vmss deallocate --resource-group aks-poc-seabnode --name aksakswin
I think powershell can run any command. I'll experiment.
@qwordy please check with az commands as its not runing in Runbook ,please refer the screenshot above
I run this command to install azure cli. This command should run as an administrator.
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi
I get an error.
Start-Process : This command cannot be run due to the error: The operation was canceled by the user.
Runbooks gallery contains many examples. But there is no CLI example.
Add a service attention label to ask for help.
can you try running commands using az as mentioned above
can you try running commands using az as mentioned above
The same result as you. Az is not installed be default. We need to install it first.
Where should we install and how that can be done
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @zjalexander.
Please note we need to run powershell scripts in Azure run books with az commands as mentioned above
This is not a supported Azure Automation scenario for Azure execution. See https://docs.microsoft.com/en-us/azure/automation/automation-runbook-execution#using-executables-or-calling-processes and https://docs.microsoft.com/en-us/azure/automation/automation-runbook-execution#where-to-run-your-runbooks
If you don't want to or can't change your script to use the PowerShell equivalent commands, you will need to use a hybrid worker.
Thank @zjalexander for quick response. Do you have any plan to support CLI scripts in runbook?
@nidiculageorge You can try hybrid worker. It needs some configuration.
https://docs.microsoft.com/en-us/azure/automation/automation-hybrid-runbook-worker
Azure Pipelines is also an option. I have written bash script which contain CLI commands in Azure Pipelines. It can run successfully.
@qwordy @zjalexander what you are saying is,that we can configure powersell scripts with az commands in azure automation run books
@qwordy no plans at this time, the product group monitors feature requests here: https://feedback.azure.com/forums/246290-automation
@nidiculageorge If you install the azure cli on a machine, and configure that machine as a hybrid worker, and use that hybrid worker to execute a runbook - yes. There's a few considerations to take when using a hybrid worker so please review https://docs.microsoft.com/en-us/azure/automation/automation-hrw-run-runbooks, especially the sections on permissions and authentication.
PowerShell is NOT portable. We shouldn't have to use a myriad of YOUR tools to support YOUR products. Please consider adding the CLI so we can all be sane with some consistency.
@zjalexander to finalize az commands wont work on Runbooks.Running CLI from our machines is not an option
Can you please clarify on my above question
@nidiculageorge Az (CLI) commands won't work on runbooks run in the Azure sandbox.
Most helpful comment
PowerShell is NOT portable. We shouldn't have to use a myriad of YOUR tools to support YOUR products. Please consider adding the CLI so we can all be sane with some consistency.