Automation Account Runbook Running on Azure VM

Jasdeep Singh 0 Reputation points
2025-07-01T23:59:19.61+00:00

Hi,

I have configured Azure Automation with a Runbook to execute on an Azure Linux VM using a Hybrid Worker. Simple scripts that do not involve any Az modules run successfully. However, when I use Az modules in my PowerShell script — for example:

(Get-AzStorageAccountKey -ResourceGroupName $sourceStorageAccountRG -Name $sourceStorageAccountName).Value[0]


—the script fails with the following error:

The term 'Get-AzStorageShare' is not recognized as the name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I want to understand what happens behind the scenes when a Runbook runs on a Hybrid Worker (Azure VM). Specifically:

  • Are the Az PowerShell modules automatically installed on the Hybrid Worker VM?
  • Or do I need to manually install them. If yes, then what approach is there for Linux VM.

Is there something I'm missing in the setup?

Any guidance would be greatly appreciated.

Thanks

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

1 answer

Sort by: Most helpful
  1. Stanislav Zhelyazkov 28,676 Reputation points MVP Volunteer Moderator
    2025-07-02T07:42:48.95+00:00

    Hi,

    Modules uploaded to Azure Automation are available only for the Azure Workers. When you deal with Hybrid workers you are responsible to keeping whatever PS modules available on the machine no matter if it is Linux or Windows. On what approach you will take of installing and maintaining PS module versions on your machine is entirely up to you. One way is that in every runbook you have to check if certain module and version is available before importing it. If it is not available you can use PS cmdlets to install it and after that import it. If it is available you can proceed to directly importing it. That way the actual download and installation will happen only when it is not available and you will not end up in situation where you have forgot to install specific module and version.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    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.