Unable to import modules to Automation account

Jan Duchač 0 Reputation points
2025-08-21T10:36:52.7166667+00:00

I have an automation account with multiple runbooks. I wanted to update one of my previously imported modules (PnP powershell), but when I go to Modules menu and select Add a module > Import from gallery, the gallery returns "Loading Failed". I have tried to upload the module manually as a ZIP file and while it seems to import the module, all commands from the module return that they are not recognized, so the module is not working. I have tested that on multiple tenants and all have this issue for past few hours.

Due to the issue I am unable to run the scripts.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
{count} votes

1 answer

Sort by: Most helpful
  1. Vinod Pittala 6,310 Reputation points Microsoft External Staff Moderator
    2025-08-21T14:27:15.54+00:00

    Hello Jan Duchač

    Firstly, PnP.PowerShell versions beyond 2.x require PowerShell 7.4+, but Azure Automation currently supports only PowerShell 5.1 and 7.2. This mismatch causes cmdlets to fail even if the module appears imported.

    So, to resolve this issue follow the below workaround.

    1. Go to the runtime environment you are using.
    2. Delete any broken PnP.PowerShell module from your Automation account using Portal or:
         Remove-AzAutomationModule -Name "PnP.PowerShell" -ResourceGroupName <RG> -AutomationAccountName <AA> -Force
      
    3. Go to the PowerShell Gallery to the page of the latest working module version (in your case 2.12): https://www.powershellgallery.com/packages/PnP.PowerShell/2.12.0
    4. Rename the downloaded .nupkg to PnP.PowerShell.zip
    5. In Azure Portal, under your Automation Account → ModulesAdd a module:
      • Choose + Add a file.
      • Upload your PnP.PowerShell.zip.
      • Wait—import can take up to 10 minutes—then verify the module shows as Available
    6. Once imported, use:
         Import-Module -Name PnP.PowerShell -RequiredVersion 2.12.0
      
      This should load the module and make its cmdlets available in your runbook

    You can refer the similar issue : https://learn.microsoft.com/en-us/answers/questions/2265480/import-pnponline-error-in-azure-automation-runbook?utm_source=chatgpt.com

    If the provided solution helpful for your query, please click Upvote it.

    Thanks

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.