Share via

How do I update custom modules (PnP.Powershell) in Azure Runbook?

Fumio 5 Reputation points
2023-03-24T16:44:49.7733333+00:00

I have an Azure automation account where a runbook uses PnP.Powershell which enables interfacing with SharePoint. However, due to a bug in an older version of PnP.Powershell, it doesn't support batching while using Add-PnPListItem. Consequently, I want to update my version of PnP.Powershell from 1.5 to 1.12.

However, I can't find any resources that point me towards updating custom modules in Azure Runbook. I can only find information on updating the AZ modules.

I thought of deleting the PnP module and importing it again but that automation account has several runbooks active and doing that would not be feasible. Please let me know if anyone has an idea of the best way to update the custom modules in Azure Runbook.

Azure Automation
Azure Automation

An Azure service that is used to automate, configure, and install updates across hybrid environments.

{count} vote

1 answer

Sort by: Most helpful
  1. SwathiDhanwada-MSFT 19,078 Reputation points Moderator
    2023-03-28T09:50:17.91+00:00

    @Fumio You can use the New-AzAutomationModule cmdlet to import a module into your Automation account. The cmdlet takes a URL for a module .zip package.

    New-AzAutomationModule -Name <ModuleName> -ContentLinkUri <ModuleUri> -ResourceGroupName <ResourceGroupName> -AutomationAccountName <AutomationAccountName>
    

    You can also use the same cmdlet to import a module from the PowerShell Gallery directly. Make sure to grab ModuleName and ModuleVersion from the PowerShell Gallery.

    $moduleName = <ModuleName>
    $moduleVersion = <ModuleVersion>
    New-AzAutomationModule -AutomationAccountName <AutomationAccountName> -ResourceGroupName <ResourceGroupName> -Name $moduleName -ContentLinkUri "https://www.powershellgallery.com/api/v2/package/$moduleName/$moduleVersion"
    
    0 comments No comments

Your answer

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