如何使用通过那里的API的请求使用公共IP地址创建Azure VM。这是当前的请求正文,但我不知道我需要添加什么才能使VM具有公共IP地址-谢谢
{
"location": "ukwest",
"properties": {
"hardwareProfile": {
"vmSize": "Standard_B1s"
},
"storageProfile": {
"imageReference": {
"id": "/subscriptions/28f23ba2-c344-448c-808b-e45a97a29764/resourceGroups/main/providers/Microsoft.Compute/images/ukproxy"
},
"osDisk": {
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"name": "myVMosdisk",
"createOption": "FromImage"
}
},
"osProfile": {
"adminUsername": "user",
"computerName": "user",
"adminPassword": "password!"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/28f23ba2-c344-448c-808b-e45a97a29764/resourceGroups/main/providers/Microsoft.Network/networkInterfaces/nic",
"properties": {
"primary": true
}
}
]
}
},
"name": "VM"
}
答案 0 :(得分:0)
公共IP仅与网络接口相关联。因此,创建虚拟机时,您无需担心公共IP。您要做的就是创建公共IP,并将其与属于VM的接口相关联。
例如,创建网络接口时,请求正文将如下所示:
{
"name": "test-nic",
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/test-nic",
"location": "eastus",
"properties": {
"provisioningState": "Succeeded",
"ipConfigurations": [
{
"name": "ipconfig1",
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/test-nic/ipConfigurations/ipconfig1",
"properties": {
"provisioningState": "Succeeded",
"privateIPAddress": "172.20.2.4",
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/test-ip"
},
"subnet": {
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/rg1-vnet/subnets/default"
},
"primary": true,
"privateIPAddressVersion": "IPv4"
}
}
],
"dnsSettings": {
"dnsServers": [],
"appliedDnsServers": []
},
"enableAcceleratedNetworking": true,
"enableIPForwarding": false
},
"type": "Microsoft.Network/networkInterfaces"
}