基于Azure资源管理器的虚拟机的保留IP [英] Reserved IP's for Azure Resource Manager based Virtual machines

本文介绍了基于Azure资源管理器的虚拟机的保留IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是双重的.首先,将保留的IP地址作为公共IP分配给基于资源管理器的虚拟机的方法是什么.它是否只涉及在模板文件中将IP分配方法设置为静态(然后将其分配给NIC,因此当然是VM),或者还有其他方法可以做到这一点,我已经在Internet上阅读了有关负载均衡器的信息,但我没有得到如何要使用模板文件使用它们,请参考任何链接. 其次,是否存在任何其他api或.net sdk来处理Azure资源管理模型中的保留IP(例如,创建,关联,取消关联方法).我已经找到了用于Azure服务管理模型的api( https://msdn.microsoft.com/library/azure/dn722420.aspx ),但对于Azure资源管理模型,我找不到相同的内容. 谢谢

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

推荐答案

保留的IP地址仅用于Classic Deploy Model,并且此功能部分已集成到公共IP地址中.静态公共IP地址的行为与保留的IP地址完全相同.无需也不可能将经典的保留IP地址分配给ARM部署的VM.将静态公共IP分配给负载均衡器与将其分配给NIC完全相同.

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确实具有用于经典保留IP地址的ARM REST API,但是我找不到任何文档.所以,我只能在这里描述一下.

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.

获取保留的IP地址.

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

标头:授权,与其他ARM REST API相同.

Headers: Authorization, the same as other ARM REST API.

响应正文:

{
    "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"
}





创建一个保留的IP地址.

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

标题:授权,与其他ARM REST API相同.内容类型,"application/json"

Headers: Authorization, the same as other ARM REST API. Content-Type, "application/json"

请求正文:

{
    "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"
}





删除保留的IP地址.

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

标头:授权,与其他ARM REST API相同.

Headers: Authorization, the same as other ARM REST API.





Rest API不支持POST或PATCH.

The Rest API does not support POST or PATCH.

对于带有Load Balancer的VM,我编写了一个示例模板.

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')]"
          }
        }
      }
    }
  ]
}

负载均衡器是在NIC和公共IP地址之间设置的负载,用于均衡Internet流量.有关更多详细信息,请参见 Azure负载均衡器概述

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

更新

关于将经典的保留IP地址转换为静态公共IP地址,这就是我所发现的.如果您按照文章"

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.

这篇关于基于Azure资源管理器的虚拟机的保留IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆