Sibeesh Venu
Sibeesh Venu

Reputation: 21809

Set-AzureRmNetworkInterface : Private static IP address does not belong to the range of subnet prefix

I have recently created a virtual machine in Azure where I have installed WordPress and MySQL in it. I have created a Web App too. Now I need to assign my static Web App IP address to the Virtual machine I created. I tried the following commands but no luck there.

New-AzureReservedIP –ReservedIPName IP –Location "South Central US" -ServiceName ServName

I am using latest Azure Powershell in my virtual machine. When I search for a solution people are saying the commands I used are not compatible with the latest powershell. So I used the commands explained here as follows.

$nic=Get-AzureRmNetworkInterface -Name networkinterfacename -ResourceGroupName resouorcegrpupname $nic.IpConfigurations[0].PrivateIpAllocationMethod = 'Static' $nic.IpConfigurations[0].PrivateIpAddress = 'ip address' Set-AzureRmNetworkInterface -NetworkInterface $nic

But when I run I am getting error as Set-AzureRmNetworkInterface : Private static IP address does not belong to the range of subnet prefix 10.0.0.0/24.

Any help is much appreciated. Thanks in advance.

Note : I have logged in to the Powershell and I am able to run the commands Add-AzureAccount, Select-AzureSubscription, Get-AzureStorageAccount.

Upvotes: 0

Views: 2077

Answers (1)

Steven Lee - MSFT
Steven Lee - MSFT

Reputation: 810

Private static IP address does not belong to the range of subnet prefix 10.0.0.0/24.

This error message has clearly described the root cause of this issue. I suppose that the static IP address doesn't reside in the subnet 10.0.0.0/24.

You have two options to overcome this issue:

  1. Change the static IP address. (Choose an available IP from the subnet 10.0.0.0/24)

  2. Create a new subnet which contains your static IP address.

Note: All the subnets must belong to same VNET. Azure doesn't support move the VM to another VNET.

Here is a good article about how to move the VMs between the subnets.

Upvotes: 1

Related Questions