Simplify Azure Automation Dependencies with Runtime Environments

Versioning of runtime and packages in Azure Automation has been a pain for a long time. All of your scripts in the same automation account will use the same version of PowerShell and have access to the same versions of any packages you install. If you update some package versions for one script, you risk breaking things for other scripts. If you want to use specific packages that can’t be used alongside other packages (such as AzureRM vs Az modules), then you can’t be sure you aren’t breaking other scripts that might rely on the other packages.

Runtime Environments is a new preview feature that aims to resolve this problem. With this feature, when you run an automation job, you are selecting two things:

  • The script you want to run
  • The runtime environment you want to use

You can create multiple runtime environments, each with different versions of PowerShell or Python and with different packages/modules and versions of these packages. You can run one script in one runtime and another in a different one and make changes to the runtime environment without impacting any others.

Getting Started

As this is a preview feature, you need to enable it. If you go to your automation account in the portal, you should see a “Try Runtime Environment Experience” button.

Try Runtime Experience

Once you select this, it will update the UI, and you should now see an option for “Runtime Environments”.

runtime environments

Once you select this, you will see that several runtime environments have already been created. You can use these system-managed environments to run jobs, but you cannot make changes to them.

System Environments

To create your own runtime environment, click the “create” button at the top. You first need to select the language (PowerShell or Python) and the version. You also need to give the environment a name.

Environment Settings

Next, you select any packages you want to install in the environment. By default, it comes with the Az Modules and the Azure CLI.


If you click “Add From Gallery”, you can add any packages from the PowerShell gallery.

PS Gallery

You can also upload your own packages directly with a zip file. Once you have selected all the required packages, click next and create. When you create a runbook, you now have a new option to choose the runtime environment.

select environment

For existing runbooks, you can select or change the runtime environment by ticking the box for that script in the runbooks page and then clicking the “Update Runtime Environment” box.

Update Runtime