How to Run Azure Automation Runbook Locally While Accessing Assets
When you work with Azure Automation, you might find yourself coding locally, putting all the initial logic into the script, copying and pasting the code to the web to run it, and then testing the code from the portal.
Usually this practice takes longer to execute and will require a printout of variables or comments to follow the code execution, as you are not debugging your script.
There is another, possibly better, way to get your PowerShell code into Azure.
You can install an add-on on your local machine that allows you to connect to Azure and interact with the different automation components. You can easily download and use this add-on locally, giving you the ability to debug your code. It is called Azure Automation PowerShell ISE add-on.
Install it with either of these two options:
You can install the ISE add-on module from PowerShell Gallery with:
Install-Module AzureAutomationAuthoringToolkit -Scope CurrentUser
Then, if you want the PowerShell ISE to always automatically load the add-on, run:
Otherwise, whenever you want to load the add-on, just run the following in the PowerShell ISE:
The add-on will prompt you to update if a newer version becomes available.
What can you do with the Azure Automation Powershell ISE Add On?
Once you installed it will appear like this.
We have multiple tabs: Configuration, Runbooks, DSC, Assets and Modules. Let's take a look at each.
Here you will sign in to Azure and select the Automation Account you wish to use.
After you log in with your credentials, a folder is created where all components are downloaded.
This tab allows you to create, open, download, upload, delete and even test a draft version or a runbook in Azure.
This tab allows you to create, open, download, upload, delete and even compile a Desire State Configuration file in Azure.
I think this is the most important area in the ISE Add-On—you can create, edit locally, download, upload, insert, or delete different assets like Credentials, Connections, Variables, or Certificates.
Like the last one, this is one of the main tabs. It allows you to see, delete, upload and select the storage to use for any module.
Once you installed and logged in you can test your code with the same commands that you have, and you can easily debug it in the same way as any normal PowerShell code you have built before. Enjoy!