An Azure service that is used to automate, configure, and install updates across hybrid environments.
Hello Kaya Elif, It looks like you’re having a tough time getting the PnP.PowerShell module to work in your Azure Automation Runbook. The errors you're encountering suggest that Azure isn't recognizing the module or cmdlets.
To answer your question:
- Yes. There are two specific requirements that must be met.
- Correct runtime alignment:
PnP.PowerShell 2.12.0is the last version officially compatible with Azure Automation PowerShell 7.2. Newer PnP versions (3.x) require PowerShell 7.4.6, which Azure Automation does not support yet in the legacy 7.2 runbook model. PnP’s own documentation explicitly states that 2.12.0 is the only stable version supported for Automation 7.2. If the runbook runtime is 7.2 and the module version is 2.12.0, the version compatibility is correct. - Module must be imported into the same runtime environment: If the module is imported into a different runtime environment than the runbook is using, PowerShell will fail. Microsoft Learn confirms that runtime environments are the execution boundary, and packages must exist inside the runtime linked to the runbook. This explains why modules can appear as Imported in the UI but still fail at runtime.
- Yes and this is the most common root cause of your exact error. Azure Automation follows PowerShell’s strict module discovery rules The ZIP must contain a single top-level folder named exactly the same as the module, and inside it the
.psd1must exist. If the ZIP instead containsPnP.PowerShell.2.12.0\Pnp.PowerShell...and or only loose files without thePnP.PowerShellfolder. Azure Automation will show the module as imported, but PowerShell cannot load it, producing exactly the error you see. - Yes. this is a known and documented limitation. PowerShell 7.2 is deprecated upstream
- Microsoft has officially stated that PowerShell 7.1 and 7.2 are no longer supported by the PowerShell product lifecycle.
- Azure Automation still supports them for backward compatibility, but module ecosystem breakage is expected.
Hope this helps. Please let me know if you need any assistance. Thanks