Ondrej Sebela Thanks, I confirmed the service principal name for the Azure Automation account using that command. The runbook does not really get stuck.What happens is that I run a test it edit mode.It completes, but I can tell the whole script has not run(as debug output statements are missing) Connect-AzAccount -Identity -> this works $MSI = (Get-AzAzureADServicePrincipal -Filter "displayName eq '$automationAccountDisplayName'")-> nothing is executed on or after this line