Hello Anita !
Thank you for posting on Microsoft Learn.
PnP PowerShell (especially from v1.x onward) targets .NET 5+ / .NET Standard 2.0+ and may not be fully compatible with the .NET Framework 4.7.2 runtime used in Azure Automation Classic Runbooks (which PowerShell 5.1 runbooks still rely on).
I think the version 0.3.1 is the last stable version and compatible with Azure Automation runbooks.
Or, you need to switch to Hybrid Runbook Worker.
https://learn.microsoft.com/en-us/azure/automation/automation-hybrid-runbook-worker