Deploying A New Container Group Using Azure PowerShell
Before starting, a MSDN account is needed to use the Azure platform, please refer to your manager for further information.
In this tutorial, the PowerShell commandlets will be used to deploy a Windows image that packages Internet Information Services (IIS).
Launch the command prompt and type az login to authenticate on the Azure platform (see below):
Wait until a browser is launched so that you can login (see below):
You have logged into Microsoft Azure!
To create a new container, the following command will be used:
- New-AzResourceGroup
- New-AzContainer Group
- Get-AzcontainerGroup
- Get-AzContainerInstanceLog
- Remove-AzResourceGroup
Open the command prompt and type powershell to start.
Define the variable resource group that will hold the container group:
- $resourceGroup = “WinIIS-Tuto” (hit enter)
Define the variable location:
- $location = “westeurope” (hit enter)
Create the resource group and the location:
- New-AzResourceGroup -Name $resourceGroup -location $location (hit enter)
The resource group and the location are now created.
Define the variable container group (only lowercase letters, numbers and dashes):
- $containerGroupName = “image-iis3” (hit enter)
Create the container group:
- New-AzContainerGroup -ResourceGroupName $resourceGroup `
- -Name $containerGroupName -Image microsoft/iis:nanoserver `
- -IpAddressType Public -DnsNameLabel wind-iis2 `
- -osType Windows -Memory 2 -Cpu 2 -RestartPolicy OnFailure
The DnsNamelabel should be unique.
Hit enter to execute the commands.
During the execution process, use the following command-line to check the status of the container group:
- Get-AzContainerGroup -ResourceGroupName `
- $resourceGroup -Name $containerGroupName
The ProvisioningState variable display the three state of creation of the container group which is pending, creating and succeeded.
A public random ip address is assigned and a fully qualified domain name which is wind-iis2.westeurope.azurecontainer.io
To check if the container is up and running, open a browser and type the FQDN.
To check the container group logs, type the following command:
- Get-AzContainerInstanceLog -ResourceGroupName `
- $resourceGroup -ContainerGroupName $containerGroupName
As a test environment and to avoid paying extra cost, make sure to delete the resource group created if not used (command-line below).
- Remove-AzResourceGroup -Name $resourceGroup -Force
Need further details about deploying a container in Azure, please check here.