Skip to main content

Running a Windows Server Container on Azure

· 2 min read

I was looking at options to run some PowerShell scripts in Azure and my first idea was: why not start a Windows Server Container with the right PowerShell modules and run the scripts there? Turns out there are better options for running PowerShell scripts in Azure (Azure Automation Runbooks) so I did not continue on this path but this is really cool technology and I learned a few things so I thought: let's write this down.

Azure Container Instances

First of all, you can run Docker containers on Azure using Azure Container Instances. ACI is not a container orchestrator like Kubernetes (AKS) but it's ideal for quickly getting single containers up-and-running. The fastest way to run a container is through the Azure CLI. You can find the CLI directly from the portal:

Azure cloud shell

Running a container

Once you have started the CLI, type or paste the following commands:

az configure --defaults location=westeurope
az group create --name DockerTest
az container create \
--resource-group DockerTest \
--name winservercore \
--image "microsoft/iis:nanoserver" \
--ip-address public \
--ports 80 \
--os-type windows

The first command sets the default resource location to westeurope so you do not have to specify this for each command. The second command creates a resource group named DockerTest and the third command starts a simple Windows Server container with the Nano Server OS, running IIS.

You need to specify a number of parameters when creating a container:

  • the name of the resource group for your container resources
  • the name of the container group
  • the name of the Dockerhub image: microsoft/iis:nanoserver
  • create a public IP address
  • specify that the container should expose port 80
  • specify the OS type (ACI does not detect this automatically)

Once you have run these commands, you can check progress via:

az container list --resource-group DockerTest -o table

And once the container has been provisioned, you should get something like this:

Progress

The container has received a public IP address, in my case 52.233.138.192 and when we go there, you see the default IIS welcome page.

IIS

Tadaaa, your first Windows Server Container running on Azure.