Fix dependencies for Azure Active Directory management
When you run Connect-MsolService from a runbook, you get this error message: Connect-MsolService : The type initializer for 'Microsoft.Online.Administration.Automation.ConnectMsolService' threw an
This issue is described in the following KB
Please solve this, so we don't need to add VM to manage this.
The MSOnline module is now available on the PowerShell Gallery: http://www.powershellgallery.com/packages/MSOnline/1.0.
You can retrieve this module to be used in Automation by clicking the “Deploy to Azure Automation” button from PowerShell Gallery.
You can also import it directly from Automation by going to your Automation account > Assets > Modules > Browse Gallery > finding MSOnline > and clicking Import.
Anders Wahlqvist commented
@Darryl - Weird, I did not add that file, worked fine anyway. I did post a step-by-step guide on my blog on how I did it, it's available at: http://dollarunderscore.azurewebsites.net/?p=6161
Hope you get it sorted out!
Darryl Kegg commented
@Anders - you zipped up the module folder, but did you also create a -automation.json file? Trying to import just the zipped module folder for me returns an error that "No valid module file was found in any directory"
Jakob Gottlieb Svendsen (MVP) commented
I can confirm that below suggestion to use the public preview module works for me too
Anders Wahlqvist commented
I zipped up the module-folder created after installing the new preview:
and imported that into Azure Automation, and Connect-MsolService now works and I can list users! Seems there's hope! :-)
This hasn't been fully addressed yet and we are looking into possibilities of updating this.
You still cannot install an MSI that the Azure AD cmdlets require on an Azure Automation worker.
However, you can use a hybrid runbook worker as a work-around for this as you can do the full install here (see https://azure.microsoft.com/en-us/documentation/articles/automation-hybrid-runbook-worker/).
Another potential workaround is to take any of the required dependencies for the cmdlets you need and include them in the .zip file before importing the module. See http://azure.microsoft.com/blog/2014/12/15/authoring-integration-modules-for-azure-automation/ for more information on this.
Joshua Toon commented
Has this been addressed? I don't see any Msol cmdlets used in the runbook gallery.
Ashley Steel commented
Hrmm this is quite a shame, as I was really hoping to use Azure Automation to plug the Azure AD<>SPO synchronisation gap. Back to the drawing board! :(
Sean M. commented
Not being able to manage office 365 from Azure Automation is a huge deflation :( I was really excited about adding some capabilities around management of O365 users, licenses, and tenants and I cannot find any way to accomplish this today
I got the same issue.... Trying to use MSOnline to assign Office 365 licenses from Azure Automation.