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 -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


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


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:




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 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:



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

Test-AzureStaticVNetIP -IPAddress -VNetName solvoit

IsAvailable : False
AvailableAddresses : {,,,…}
OperationDescription : Test-AzureStaticVNetIP
OperationId : ca9a689e-7166-b8d0-9fbc-d25fa2e6010b
OperationStatus : Succeeded

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: Logo

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

Facebook photo

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

Connecting to %s