Image
{{'2019-05-22T23:05:03.3995257Z' | utcToLocalDate }}
Ben Howard

Azure Automation Module Import: Sorry! You’re not my type.

I’ve just burnt several hours on an issue with importing powershell modules into an Azure automation account using the

New-AzureRmAutomationModule cmdlet.  Although I could import the module with no issue using the portal, I was getting an error of “Import newer version failed” when trying to do it using the cmdlet, and when I checked the module in the portal the message was:

“Error importing the module cAsosSQLAddons. Import failed with the following error: Orchestrator.Shared.AsyncModuleImport.ModuleImportException: No content was read from the supplied ContentLink. [ContentLink.Uri=https://xxxxx.blob.core.windows.net/dscresources/DSCResources

.cXXXXSQLAddons/1.0.9/cXXXXSQLAddons.zip]”

When importing a module using New-AzureRmAutomationModule, one of the parameters you must supply is ContentLinkUri.  Since my module exists as blob storage in a container, I was using the New-AzureStorageBlobSASToken cmdlet to get a URI with a SAS token for the zip file and passing that. However, the New-AzureStorageBlobSASToken cmdlet returns a string, and this is NOT what you should use.  The ContentLinkUri paramter expects an object of type System.Uri . So, you should cast the result to a URI object first:

Once I passed the correct object type, it all started working!

comments powered by Disqus