该问题是双重的。首先,将保留的IP地址作为公共IP分配给基于资源管理器的虚拟机的方法是什么。它是否只涉及将IP分配方法设置为模板文件中的静态(然后将其分配给NIC,因此将其分配给VM)或者还有其他方法可以做到这一点,我已经通过互联网阅读了有关负载均衡器但是我没有得到如何要使用模板文件,请参阅任何链接。 其次,是否存在任何其他api或.net sdk来处理Azure资源管理模型中的保留IP(例如,创建,关联,取消关联方法)。我找到了Azure服务管理模型的api(https://msdn.microsoft.com/library/azure/dn722420.aspx),但我没有找到相同的Azure资源管理模型。 感谢
答案 0 :(得分:2)
保留的IP地址仅适用于Classic Deploy Model,此部分功能已集成到公共IP地址中。静态公共IP地址的作用与保留的IP地址完全相同。不需要也不可能为ARM部署的VM分配经典的保留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
标题:授权,与其他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
标题:授权,与其他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相同。
Rest API不支持POST或PATCH。
对于带有Load Balancer的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和公共IP地址之间设置的东西,负载平衡互联网流量。有关详细信息,请参阅Azure Load Balancer overview
<强>更新强>
关于将经典保留IP地址转换为静态公共IP地址,这是我发现的。如果您按照文章“Migrate IaaS resources from classic to Azure Resource Manager by using Azure PowerShell”,将保留的IP分配给具有虚拟机的Cloud Service,并将ASM虚拟机迁移到ARM虚拟机,则保留的IP将转换为静态公共IP。我已经使用虚拟网络测试了虚拟机。它确实有效。