The Question is twofold. Firstly, What is the way to assign a reserved IP address as a public IP to a resource manager based virtual machine. Does it only involve setting IP allocation method to static in template file (then assigning that to NIC hence the VM of course) or there is some other way to do this, i have read over the internet about load balancers but i am not getting how to use them using a template file, please refer any links. Secondly, does any rest api or .net sdk exist to deal with reserved IPs in Azure Resource Management model (e.g. Create, associate, disassociate methods). I have found the api for Azure service management model (https://msdn.microsoft.com/library/azure/dn722420.aspx) but i am not finding the same for Azure resource management model. Thanks
1 Answers
A reserved IP address is for Classic Deploy Model only, and this part of functionality is integrated into the public IP address. A static public IP address acts exactly like a reserved IP address. No need and not possible to assign a classic reserved IP address to an ARM deployed VM. Assigning a static public IP to a load balancer is exactly the same as assigning one to a NIC.
Microsoft does have ARM REST API for classic reserved IP address, but I can't find any documents. So, I can only describe it here a little bit.
Get a reserved IP address.
GET https://management.azure.com/subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.ClassicNetwork/ReservedIps/<reserved IP address name>?api-version=2015-12-01
Headers: Authorization, the same as other ARM REST API.
Response body:
{
"properties": {
"ipAddress": "<ip address>",
"status": "Created",
"provisioningState": "Succeeded",
"inUse": false
},
"id": "/subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.ClassicNetwork/ReservedIps/<reserved ip address name>",
"name": "<reserved ip address name>",
"type": "Microsoft.ClassicNetwork/ReservedIps",
"location": "eastasia"
}
Create a reserved IP address.
PUT https://management.azure.com/subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.ClassicNetwork/ReservedIps/<reserved IP address name>?api-version=2015-12-01
Headers: Authorization, the same as other ARM REST API. Content-Type, "application/json"
Request body:
{
"properties": {
},
"id": "/subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.ClassicNetwork/ReservedIps/<reserved ip address name>",
"name": "<reserved ip address name>",
"type": "Microsoft.ClassicNetwork/ReservedIps",
"location": "eastasia"
}
Delete a reserved IP address.
DELETE https://management.azure.com/subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.ClassicNetwork/ReservedIps/<reserved IP address name>?api-version=2015-12-01
Headers: Authorization, the same as other ARM REST API.
The Rest API does not support POST or PATCH.
For VM with Load Balancer, I have written a sample template.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountName": {
"type": "string",
"defaultValue": "loadbalancertest2",
"metadata": {
"description": "The Storage Name of you VM OSDisk and DataDisk"
}
},
"apiVersion": {
"type": "string",
"defaultValue": "2016-03-30",
"metadata": {
"description": "The API Version"
}
},
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"metadata": {
"description": "The Storage Account Type"
}
},
"publicIPAddressName": {
"type": "string",
"defaultValue": "loadbalancertest",
"metadata": {
"description": "The public IP Address Name"
}
},
"publicIPAddressType": {
"type": "string",
"defaultValue": "Static",
"metadata": {
"description": "The public IP Address Type"
}
},
"dnsNameforLBIP": {
"type": "string",
"defaultValue": "loadbalancertest",
"metadata": {
"description": "a unique DNS Name for LBIP"
}
},
"virtualNetworkName": {
"type": "string",
"defaultValue": "loadbalancertest",
"metadata": {
"description": "The Virtual Network Name"
}
},
"nicName": {
"type": "string",
"defaultValue": "loadbalancertest",
"metadata": {
"description": "The Network Interface Card Name"
}
},
"loadBalancerName": {
"type": "string",
"defaultValue": "loadbalancertest",
"metadata": {
"description": "The Load Balancer Name"
}
},
"vmName": {
"type": "string",
"defaultValue": "lbtest",
"metadata": {
"description": "The Virtual Machine Name"
}
},
"adminUsername": {
"type": "string",
"metadata": {
"description": "The admin Username"
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "The admin Password"
}
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_D1",
"metadata": {
"description": "The Virtual Machine Size"
}
}
},
"variables": {
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',parameters('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/default')]",
"publicIPAddressID": "[resourceId('Microsoft.Network/publicIPAddresses',parameters('publicIPAddressName'))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[parameters('storageAccountName')]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"properties": {
"accountType": "[parameters('storageAccountType')]"
}
},
{
"apiVersion": "[parameters('apiVersion')]",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[parameters('publicIPAddressName')]",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "[parameters('publicIPAddressType')]",
"dnsSettings": {
"domainNameLabel": "[parameters('dnsNameforLBIP')]"
}
}
},
{
"apiVersion": "[parameters('apiVersion')]",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('virtualNetworkName')]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
"subnets": [
{
"name": "default",
"properties": {
"addressPrefix": "10.0.0.0/24"
}
}
]
}
},
{
"apiVersion": "[parameters('apiVersion')]",
"type": "Microsoft.Network/networkInterfaces",
"name": "[parameters('nicName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
"[concat('Microsoft.Network/loadBalancers/', parameters('loadBalancerName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('subnetRef')]"
}
},
"loadBalancerBackendAddressPools": [
{
"id": "[concat('Microsoft.Network/loadBalancers/', parameters('loadBalancerName'), '/backendAddressPools/loadBalancerBackEnd')]"
}
]
}
]
}
},
{
"apiVersion": "[parameters('apiVersion')]",
"name": "[parameters('loadBalancerName')]",
"type": "Microsoft.Network/loadBalancers",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', parameters('publicIPAddressName'))]"
],
"properties": {
"frontendIPConfigurations": [
{
"name": "loadBalancerFrontEnd",
"properties": {
"publicIPAddress": {
"id": "[variables('publicIPAddressID')]"
}
}
}
],
"backendAddressPools": [
{
"name": "loadBalancerBackEnd"
}
],
"loadBalancingRules": [
],
"probes": [
]
}
},
{
"apiVersion": "[parameters('apiVersion')]",
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]",
"[concat('Microsoft.Network/networkInterfaces/', parameters('nicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2012-R2-Datacenter",
"version": "latest"
},
"osDisk": {
"name": "osdisk",
"vhd": {
"uri": "[concat('http://',parameters('storageAccountName'),'.blob.core.windows.net/vhds/loadbalancertestOS.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
},
"dataDisks": [
{
"name": "datadisk1",
"diskSizeGB": "100",
"lun": 0,
"vhd": {
"uri": "[concat('http://',parameters('storageAccountName'),'.blob.core.windows.net/vhds/loadbalancertestData.vhd')]"
},
"createOption": "Empty"
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',parameters('nicName'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": "true",
"storageUri": "[concat('http://',parameters('storageAccountName'),'.blob.core.windows.net')]"
}
}
}
}
]
}
A Load Balancer is something set between NICs and public IP addresses, load balancing the internet traffic. For more details, see Azure Load Balancer overview
Update
About converting a classic reserved IP address into a static public IP address, here is what I have found. If you follow the article "Migrate IaaS resources from classic to Azure Resource Manager by using Azure PowerShell", assign the reserved IP to a Cloud Service with a Virtual Machine, and migrate the ASM virtual machine into an ARM virtual machine, the reserved IP will be converted into a static public IP. I have tested a virtual machine with a virtual network. It does work.

- 2,257
- 12
- 23
-
Hi, Thanks a lot for such detailed information, what is the way to associate a reserved IP address with a resource (i.e. VM or load balancer). if it is to be assigned to a VM through a load balancer, in which way we can define a reserved IP for a load balancer, Is there an API call for that as in service managment API we can easily associate a reserved IP with cloud service using an API call. So does there such API call exist? – Muhammad Murad Haider Apr 15 '16 at 13:41
-
I have written a sample template for you. – Jack Zeng Apr 18 '16 at 02:06
-
Thanks a lot! just one thing i am confused about is the parameter 'publicIPAddressName'. Could it be the name of reserved ip address? If yes, then why would we be needing to create an IP address resource through template file if a reserved IP address would be existing already? Actually my concern is to use a reserved IP for a VM – Muhammad Murad Haider Apr 18 '16 at 13:12
-
Again, a reserved IP address is for classic deploy model. For Resource Manager deploy model, you have to use a static public IP address. If you check the resource IDs, you will see that a reserved IP address belongs to Microsoft/ClassicNetwork resource provider, while a static public IP address belongs to Microsoft/Network. They are two different things with similar functionality. If you already have a public ip address, yes, sure you can delete the IP address creation from the template. – Jack Zeng Apr 19 '16 at 01:19
-
Then i am surprised why API calls to create/delete/get the reserved ip exist. we can create a reserved ip in a resource group in ARM, what its use. My purpose of using reserved ip was to resuse an IP for virtual machines in order to make firewall rules for specific ip's. The VMs in my scenario get created and deleted after a particular interval. So, is there anyway that i could have a predefined static IP for virtual machines?? – Muhammad Murad Haider Apr 19 '16 at 12:40
-
I see what you need. I will do some digging on how to convert a reserved IP address to a static public IP address. – Jack Zeng Apr 20 '16 at 06:44
-
Thanks and i think a 'static' PIP can also be used in this scenario. – Muhammad Murad Haider Apr 20 '16 at 12:20
-
Jack, were you able to find anything about converting a classic reserved IP address to a static public IP address? – James Brantly Aug 03 '16 at 19:17
-
1Yes, take a look at [Migrate IaaS resources from classic to Azure Resource Manager by using Azure PowerShell](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-ps-migration-classic-resource-manager/). If you assign the reserved IP to a Cloud Service with a Virtual Machine, and migrate the ASM virtual machine into an ARM virtual machine, the reserved IP will be converted into a static public IP. – Jack Zeng Aug 04 '16 at 09:14