The Azure automation service is extremely powerful especially when combined with the power of the new Azure resource manager powershell commandlets. The problem is today by default, only the Azure service manager commandlets are imported in the Azure Automation service. This article will walk you through how to import the latest version of the Azure RM PowerShell commandlets into your Azure Automation account.
- Existing Azure automation account created
- On your local machine: installed the latest version of the Azure PowerShell Commandlets
- On your local machine: configured PowerShell to connect to the Azure subscription where your automation account resides
Note: all tasks below performed from your local machine
Task 1 – Zip up the Azure and Azure RM PowerShell commandlets
- Open Explorer window and navigate to %programfiles(x86)%\Microsoft SDKs\Azure\PowerShell\ResourceManager folder.
- Right-click on AzureResourceManager folder and select Send To | Compressed (zipped) folder. Save to a known location (desktop is fine).
- Open Explorer window and navigate to %programfiles(x86)%\Microsoft SDKs\Azure\PowerShell\ServiceManagement folder.
- Right-click on Azure folder and select Send To | Compressed (zipped) folder. Save to a known location (desktop is fine).
Task 2 – Upload the zip files to a public location
Now you’ll need to upload these 2 zip files to a publicly accessible location on the internet. In the example URL below, I uploaded to a blob storage account which I made public.
Task 3 – Import the Azure PowerShell commandlet modules into your Azure Automation Account using PowerShell
Run the following 2 PowerShell commands to import the modules:
New-AzureAutomationModule -AutomationAccountName devopsautomation -ContentLink https://<yourstorageaccount>.blob.core.windows.net/<yourcontainername>/AzureResourceManager.zip -Name AzureResourceManager -ResourceGroupName devopsSubscriptionManagement
New-AzureAutomationModule -AutomationAccountName devopsautomation -ContentLink https://<yourstorageaccount>.blob.core.windows.net/<yourcontainername>/Azure.zip -Name AzureResourceManager -ResourceGroupName devopsSubscriptionManagement
After you execute the commandlet you should see the provisioning state to “creating”. If not, your zip file referenced might not be publicly accessible.
If you immediately go into the portal you’ll notice that the module is there, but there are no activities present yet. This is because it takes some time for the activites to import and process in the background. After several minutes, you should be able to refresh the portal and see the modules listed. Now you’re able to use any of these commandlets for Azure RM with the Azure Automation Service!