Microsoft Azure – Unable to allocate required IP address

I ran into an issue today, when deploying a new VM in Azure. I’ve made a script to ease VM creation in Azure for myself and my colleagues (will publish this when it’s ready for general use) but I kept getting this error:

[powershell]New-solvoitVM -VMName SOFTWARE1 -CloudService internal -VMSize A1 -OperatingSystem WS2012R2 -IPAddress 10.4.3.12 -Basic
New-AzureVM : Networking.DeploymentVNetAddressAllocationFailure : Unable to allocate the required address spaces for the deployment in a new or predefined
subnet that is contained within the specified virtual network.
At C:Usersjj-adminDesktopNew-solvoVM.ps1:101 char:9
+ New-AzureVM -VMs $vm -ServiceName $cloudService -VNetName $vnetName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureVM], CloudException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.PersistentVMs.NewAzureVMCommand
[/powershell]

 

But.. I already checked the portal and this IP was not listed:
azure_ips

 

I tried to refresh, ask around if anyone had just had this IP in use and deleted the VM (Azure can be a bit slow to update available IP’s), but nothing appeared. A colleague suggested to check the IP with nslookup, and there it was:

[powershell]

nslookup 10.4.3.12
Server: dns1.company.com
Address: 192.168.5.14

Name: VM2.company.com
Address: 10.4.3.12
[/powershell]

This server existed in Azure, but was never assigned a static IP. The guy who created it, had set a static IP inside Windows on the VM using 10.4.3.12 instead of using Azure PowerShell to assign it. As you can see the IP is not listed in the portal or if I try to get the IP via PowerShell:

azure_ips2

Nothing…

I then glanced through the Azure cmdlets containing “*IP*” and discovered this command:

[powershell]
Test-AzureStaticVNetIP -IPAddress 10.4.3.12 -VNetName solvoit

IsAvailable : False
AvailableAddresses : {10.4.3.6, 10.4.3.14, 10.4.3.15, 10.4.3.16…}
OperationDescription : Test-AzureStaticVNetIP
OperationId : ca9a689e-7166-b8d0-9fbc-d25fa2e6010b
OperationStatus : Succeeded
[/powershell]

Somehow Azure knew the IP address was used inside a VM, but it wasn’t visible in the portal or on the VM object itself… I’ll have to implement this cmdlet in my script! 🙂

This is another reason not to set the IP address in the OS!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s