为基于 Azure 资源管理器的虚拟机保留 IP
Reserved IP's for Azure Resource Manager based Virtual machines
问题是双重的。首先,将保留 IP 地址作为 public IP 分配给基于资源管理器的虚拟机的方法是什么。它只涉及在模板文件中将 IP 分配方法设置为静态(然后将其分配给 NIC,因此当然是 VM)还是有其他方法可以做到这一点,我已经在互联网上阅读了有关负载平衡器的信息,但我不知道如何要使用模板文件使用它们,请参考任何链接。
其次,是否存在任何其他 api 或 .net sdk 来处理 Azure 资源管理模型中的保留 IP(例如,创建、关联、取消关联方法)。我找到了 Azure 服务管理模型 (https://msdn.microsoft.com/library/azure/dn722420.aspx) 的 api,但我没有找到 Azure 资源管理模型。
谢谢
保留IP地址仅供经典部署模型使用,这部分功能已集成到publicIP地址中。静态 public IP 地址的作用与保留 IP 地址完全相同。不需要也不可能将经典保留 IP 地址分配给 ARM 部署的 VM。将静态 public IP 分配给负载均衡器与将 IP 分配给 NIC 完全相同。
Microsoft 确实有用于经典保留 IP 地址的 ARM REST API,但我找不到任何文档。所以,我只能在这里稍微描述一下。
获取保留的 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
Headers:授权,与其他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 地址。
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:授权,与其他ARM REST相同API。内容类型,"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
Headers:授权,与其他ARM REST相同API。
其余API不支持POST或PATCH。
对于带有负载均衡器的 VM,我已经编写了一个示例模板。
{
"$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 和 public IP 地址之间的东西,用于对 Internet 流量进行负载均衡。有关详细信息,请参阅 Azure Load Balancer overview
更新
关于将经典保留 IP 地址转换为静态 public IP 地址,这是我找到的。如果按照“Migrate IaaS resources from classic to Azure Resource Manager by using Azure PowerShell”一文,将reserved IP分配给Cloud Service with a Virtual Machine,将ASM虚拟机迁移到ARM虚拟机,reserved IP会转为静态public 知识产权。我用虚拟网络测试了虚拟机。它确实有效。
问题是双重的。首先,将保留 IP 地址作为 public IP 分配给基于资源管理器的虚拟机的方法是什么。它只涉及在模板文件中将 IP 分配方法设置为静态(然后将其分配给 NIC,因此当然是 VM)还是有其他方法可以做到这一点,我已经在互联网上阅读了有关负载平衡器的信息,但我不知道如何要使用模板文件使用它们,请参考任何链接。 其次,是否存在任何其他 api 或 .net sdk 来处理 Azure 资源管理模型中的保留 IP(例如,创建、关联、取消关联方法)。我找到了 Azure 服务管理模型 (https://msdn.microsoft.com/library/azure/dn722420.aspx) 的 api,但我没有找到 Azure 资源管理模型。 谢谢
保留IP地址仅供经典部署模型使用,这部分功能已集成到publicIP地址中。静态 public IP 地址的作用与保留 IP 地址完全相同。不需要也不可能将经典保留 IP 地址分配给 ARM 部署的 VM。将静态 public IP 分配给负载均衡器与将 IP 分配给 NIC 完全相同。
Microsoft 确实有用于经典保留 IP 地址的 ARM REST API,但我找不到任何文档。所以,我只能在这里稍微描述一下。
获取保留的 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
Headers:授权,与其他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 地址。
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:授权,与其他ARM REST相同API。内容类型,"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
Headers:授权,与其他ARM REST相同API。
其余API不支持POST或PATCH。
对于带有负载均衡器的 VM,我已经编写了一个示例模板。
{
"$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 和 public IP 地址之间的东西,用于对 Internet 流量进行负载均衡。有关详细信息,请参阅 Azure Load Balancer overview
更新
关于将经典保留 IP 地址转换为静态 public IP 地址,这是我找到的。如果按照“Migrate IaaS resources from classic to Azure Resource Manager by using Azure PowerShell”一文,将reserved IP分配给Cloud Service with a Virtual Machine,将ASM虚拟机迁移到ARM虚拟机,reserved IP会转为静态public 知识产权。我用虚拟网络测试了虚拟机。它确实有效。