Windows Azure uses the DHCP Protocol to assign IP Addresses. To ensure that a Server always receive the same IP the IP has to be reserved.

In Azure the IP will not be setup fixed on the target Server but rather a reservation in DHCP will be created.

This can be archived with the following PowerShell Script:

Note: This requires a Public Setting file. The necessary Steps are described here.


$modulePath = "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1"
Import-Module $modulePath
$PublishSettings = "C:\PUBLISHSETTINGSFILE.publishsettings"
cd c:\
Import-AzurePublishSettingsFile $PublishSettings
$SubscriptionName = "SUBSCRIPTIONNAME" # DEFINE Subscription HERE

Select-AzureSubscription -SubscriptionName $SubscriptionName

Write-Host "Get Azure VMs"
$AzureVMs = $(Get-AzureVM)

foreach($AzureVM in $AzureVMs)
    Write-Host "Got $($AzureVM.Name) in Service $($AzureVM.ServiceName)"
    if(!$(Get-AzureVM -ServiceName $($AzureVM.ServiceName) -Name $($AzureVM.Name) | Get-AzureStaticVNetIP) )
        Write-Host "VM $($AzureVM.Name) has no static IP"
        $IP = $(Get-AzureVM -ServiceName $($AzureVM.ServiceName) -Name $($AzureVM.Name)).IpAddress
        Write-Host "VM $($AzureVM.Name) has the following dynamic IP: $IP"        
        Write-Host "VM $($AzureVM.Name) set to $IP"
        Get-AzureVM -ServiceName $($AzureVM.ServiceName) -Name $($AzureVM.Name)|Set-AzureStaticVNetIP -IPAddress $IP| Update-AzureVM
        $StaticIP = $(Get-AzureVM -ServiceName $($AzureVM.ServiceName) -Name $($AzureVM.Name) | Get-AzureStaticVNetIP).IPAddress
        Write-host "VM $($AzureVM.Name) was set to the following IP:  $StaticIP"
        $StaticIP = $(Get-AzureVM -ServiceName $($AzureVM.ServiceName) -Name $($AzureVM.Name) | Get-AzureStaticVNetIP).IPAddress
        Write-host "VM $($AzureVM.Name) has already the following static IP: $StaticIP"

As always no guarantee 😉