Search code examples
moduleazure-automationazure-bicep

Can't Import Automation Account Storage Module using Bicep


Hi im trying to import an automaiton account module to an Automatino account that i have Using Bicep

the Module

  • Az.Storage
  • version : 2.0.0

Following the Documentation im using this code :

 resource znssPSModulesAzStorageName 'Microsoft.Automation/automationAccounts/modules@2020-01-13-preview' = {
   name: psModules.azStorage.name
   location: location
   parent: znssAutomationAccountName
   tags:{}
   properties: {
     contentLink:{
       uri: 'https://www.powershellgallery.com/api/v2/packages/Az.Storage/2.0.0'
          
     }
   }
 }

but im getting this error :

Error importing the module Az.Storage. Import failed with the following error: Orchestrator.Shared.AsyncModuleImport.ModuleImportException: No content was read from the supplied ContentLink. [ContentLink.Uri=https://www.powershellgallery.com/api/v2/packages/Az.Storage/2.0.0] at Orchestrator.Activities.GetModuleContentActivity.ExecuteInternal(CodeActivityContext context, String contentUri, String contentHashAlgorithm, String contentHashValue, String contentVersion, String moduleName, ModuleLanguage moduleLanguage) at Orchestrator.Activities.GetModuleContentActivity.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

is there a problem with the link in powershell Gallery i searched in the internet and couldn't find anything useful

hope someone can help me


Solution

  • the Problem is in the uri instead of :

    uri: 'https://www.powershellgallery.com/api/v2/packages/Az.Storage/2.0.0

    use : package singular wihout the s

    uri: 'https://www.powershellgallery.com/api/v2/package/Az.Storage/2.0.0

    it should work :

    resource znssPSModulesAzStorageName 'Microsoft.Automation/automationAccounts/modules@2020-01-13-preview' = {
       name: psModules.azStorage.name
       location: location
       parent: znssAutomationAccountName
       tags:{}
       properties: {
         contentLink:{
           uri: 'https://www.powershellgallery.com/api/v2/package/Az.Storage/2.0.0'
              
         }
       }
     }