In this blog post, we’ll show you how to run Azure PowerShell cmdlets using Docker containers.
Table of contents
Azure PowerShell provides a familiar PowerShell interface to manage Azure resources and infrastructure. It enables you to automate tasks, provision resources, and integrate scripting into CI/CD pipelines in Azure DevOps. As of its version 14 release, Azure PowerShell supports 100% of all Azure services, giving organizations the ability to automate business processes and reduce manual operations via the Azure portal.
Running Azure PowerShell from a Docker container offers several key benefits:
- No local installation required: Azure PowerShell runs from an isolated Docker image, eliminating the need to install or manage it locally.
- Support for multiple versions: You can run different versions of Azure PowerShell in containers, which is helpful when newer versions lack support for specific cmdlets.
- Always up to date: The image runs the latest stable release by default.
- Multi-environment support: Easily manage multiple Azure environments without repeatedly signing in and out.
Prerequisites
To get started, ensure you have the following installed:
- WSL (Windows Subsystem for Linux) for Windows users
- Docker Desktop

Pull the Azure PowerShell Docker Image
Download the official Azure PowerShell Docker image with:
docker pull mcr.microsoft.com/azure-powershell:latest
Run the Container and Connect to Azure
Launch a container using:
docker run -it mcr.microsoft.com/azure-powershell:latest
Once inside the container, authenticate with Azure:
Connect-AzAccount -UseDeviceAuthentication
You can now begin executing Azure PowerShell commands.
Running Scripts from Your Local Machine
To run scripts stored on your local machine, mount a folder into the container:
docker run -it --rm -v C:\\localfolder:/data mcr.microsoft.com/azure-powershell:latest
Inside the container, the mounted folder will appear at /data
, allowing access to your local scripts.
Using Docker to run Azure PowerShell is a simple and powerful way to streamline automation without cluttering your local development environment.
Discover more from CPI Consulting Pty Ltd Experts in Cloud, AI and Cybersecurity
Subscribe to get the latest posts sent to your email.