Set Azure VM Static IP Address

Set Azure VM Static IP Address

Q: How do I set a static IP address for a virtual machine (VM) in Windows Azure IaaS?

A: Prior to Windows Azure PowerShell, it wasn't possible to give a VM in a virtual network subnet a static IP address that persisted even if the VM was deprovisioned (shutdown from the portal) and therefore no long billed for.

The only option was to create different virtual subnets for different groups of VMs to try and control the IP address the VM would be given from Windows Azure.

RELATED: Video: Using Static IP Addresses in Azure

The Virtual Network static IP feature is now available through PowerShell ( and later), which is available at the Window Azure website. This enables a static IP to be assigned to a VM that will persist with the VM, even if it's deprovisioned. The VM must be within a virtual network to have a static IP address configured. There are four cmdlets used:

  • Set-AzureStaticVNetIP - Sets a static IP address, e.g. Set-AzureStaticVNetIP -VM <VM> -IPAddress <IP address string>
  • Get-AzureStaticVNetIP - Gets the static IP address of the passed VM
  • Remove-AzureStaticVNetIP - Removes the static IP address of the passed VM
  • Test-AzureStaticVNetIP - Checks to see if a certain static IP address is available from a virtual network, e.g., Test-AzureStaticVNetIP -VNetName <network name> -IPAddress <IP address string>

As a best practice, don't mix VMs using static IP addresses with VMs using DHCP within a subnet. Instead, create dedicated subnets within the virtual network that will be used for VMs using static IP addresses. Below is an example of these cmdlets in action in my environment, but this won't actually take effect until the Windows Azure region you're using has implemented this functionality:

PS C:\> Test-AzureStaticVNetIP -VNetName SavTechNet115 -IPAddress

IsAvailable          : False
AvailableAddresses   : {,,,}
OperationDescription : Test-AzureStaticVNetIP
OperationId          : c6f70cc4-bf36-7907-9c7e-bc1c2e925cbb
OperationStatus      : Succeeded

PS C:\> Test-AzureStaticVNetIP -VNetName SavTechNet115 -IPAddress

IsAvailable          : True
AvailableAddresses   : {}
OperationDescription : Test-AzureStaticVNetIP
OperationId          : 30d13740-42a3-724a-8dc8-0f418a6a6af9
OperationStatus      : Succeeded

PS C:\> $staticVM = Get-AzureVM -ServiceName savnetazu115 -Name TestStaticVM

PS C:\> Set-AzureStaticVNetIP -VM $staticVM -IPAddress | Update-AzureVM

PS C:\> Get-AzureStaticVNetIP -VM $staticVM


I walk through this whole process in my video Using Static IP Addresses in Azure

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.