Update from MSFT: 2/22/2016: To respond to a common user question, right now there is no timeline on when additional modules / new versions of modules will be shipped out of box in the Automation service. If you have additional requirements besides what we currently ship globally, these modules / module versions will have to be imported as user modules. Please note the new guidance is that if the latest version of any Azure/AzureRM module is imported as a user module to an automation account, the latest versions of ALL Azure/AzureRM modules (not just the ones that ship out of the box in Azure Automation) should be imported to the automation account, to avoid any version mismatch issues that could occur now or in the future if Azure Automation later ships any additional (or newer version) Azure/AzureRM modules as global modules.

 

Azure Automation has updated to WMF 5.0 which means that it is no longer required to required to change anything but zip the modules into zip files and upload!

I have simplified this script to do exactly that.

NOTE: The AzureRM Modules are automatically deployed in your account as global modules. Only import your own if you need a newer version or a module that is not shipped out-of-the box yet.

If you do decide to import your own, then please replace all the modules, to make sure you do not have any version mismatches.

this is the script:

# //***************************************************************************
# // Author:	Jakob Gottlieb Svendsen, Coretech A/S. https://blog.ctglobalservices.com/jgs
# // Purpose:   Find, download and zip AzureRM 0.10.0 Modules. 
# //			This script moves the files inside the modules to make them work in Azure Automation
# //            Import AzureRM.profile first, then add any modules you need.
# // CORETECH A/S History:
# // 1.0.0     JGS 10/12/2015  Created initial version.
# // 1.1.0     JGS 10/15/2015  Added rename of AzureRm.Resources\0.10.0 to make it import properly in AzureAutomation + support for other versions than 0.10.0
# // 1.1.2     JGS 02/10/2016  Azure Automation now supports normal folder structure for PS5 modules. Simplified script to not move stuff around
# // 1.1.3     JGS 02/23/2016  Added azure and azure.storage modules
# //
# // ***** End Header *****
# //***************************************************************************
$folder = "C:\azurePS"

Find-Module -Name AzureRM.*  | Save-Module -force -Path $folder
Find-Module -Name Azure  | Save-Module -force -Path $folder
Find-Module -Name Azure.Storage  | Save-Module -force -Path $folder

$dirs = dir $folder -Directory

$dirs | Foreach {
    $source = $_.FullName
    $destination = "$($_.FullName).zip"
    
    If(Test-path $destination) {Remove-item $destination}
    
    Add-Type -assembly "system.io.compression.filesystem"
    [io.compression.zipfile]::CreateFromDirectory($Source, $destination,[System.IO.Compression.CompressionLevel]::Optimal,$true) 
}

#//----------------------------------------------------------------------------
#//  End Script
#//----------------------------------------------------------------------------

Now Import Azure.profile, wait for it to show its activities and then afterwards import all other Azure /AzureRM Modules

image

NOTE: you can also import them directly from the new built in gallery:

clip_image002

Then use it in a runbook:

$AzureCreds = Get-AutomationPSCredential -Name 'Azure Credentials (Coretech)'
Login-AzureRmAccount -Credential $AzureCreds

$PSDefaultParameterValues = @{
                              "*AzureRmAutomation*:ResourceGroupName" = "blahblah-West-Europe" 
                              "*AzureRmAutomation*:AutomationAccountName" = "blahAutomation"
                            }

$runbooks = Get-AzureRmAutomationRunbook

write-warning $runbooks.count

Need training in Service Management Automation (Same techniques can be used in Azure Automation)?

Next run in Stockholm,Sweden

http://labcenter.se/Workshop?ref=Jakob.Svendsen#lab=Windows_Azure_Pack_-_Mastering_Service_Management_Automation

Also available in Denmark, Norway and U.S.. Email me for info.