Using Locally with Azure PowerShell

Preview

Sign in during Public Preview to get the Team plan free, plus an early-adopter discount when we launch. Sign in

Using Locally with Azure PowerShell

Azure PowerShell is a set of PowerShell modules (Az) for managing Azure resources. Azure PowerShell supports Automatic Configuration - if you launch PowerShell via locally run, any cmdlets you run within that session will run against Locally.

This guide was tested using the following module versions, but newer versions should work too:

  • Az - v16.3.0
  • Microsoft.Entra - v1.3.0

Provisioning a Resource Group

In this example we're going to provision a Resource Group within the First Subscription. If you haven't already installed the Az modules, from within a PowerShell session run:

$ Install-Module -Name Az -Force

If Locally isn't already running, we'll need to start it by running:

$ locally build

We can then launch PowerShell via locally run:

$ locally run pwsh

Or on Windows:

$ locally run pwsh.exe

Any cmdlets run within this session will run against Locally - for example, to create a Resource Group:

$ New-AzResourceGroup -Name "hello-powershell" -Location "berlin"

Whilst this example creates a Resource Group, you can use any cmdlets where the Resource Provider and API Version are available in Locally. Note that PowerShell needs to be launched on its own via locally run - to run a script, launch PowerShell first and then run the script from within that session.

Microsoft Entra

The Microsoft.Entra modules work the same way - within a locally run session, Entra cmdlets run against the Directory (Entra) Emulator rather than a real tenant. If you haven't already installed them, from within a PowerShell session run:

$ Install-Module -Name Microsoft.Entra -Force

For example, to list the Users within your local tenant:

$ Get-EntraUser

Next steps

The Examples include more Azure PowerShell scripts, and Subscriptions, Tenants & Credentials covers the Subscriptions, users and service principals Locally sets up for you.

Should you encounter any issues, please take a look at the troubleshooting section.

Preview

Sign in during Public Preview to get the Team plan free, plus an early-adopter discount when we launch. Sign in

A local cloud for you and your agents.

Your Azure infrastructure, running on your machine. Deploy in seconds, break things freely, and ship to Azure when you're ready.