首页 > 解决方案 > 为网络接口 ID 创建 Azure 虚拟机 REST API 引发 404

问题描述

在与网络接口相同的资源组中创建 VM 时链接网络接口(使用https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/createorupdate#create_a_vm_with_password_authentication 。)会引发此问题错误(我是连接到网络接口的虚拟网络子网的所有者):

错误:

{
  "error": {
    "details": [],
    "code": "NotFound",
    "message": "Resource /subscriptions/40fbe15/resourceGroups/sym/providers/Microsoft.Network/networkInterfaces/deletethis374 not found."
  }
}

请求详情:

网址:https ://management.azure.com/subscriptions/40fbe15/resourceGroups/sym/providers/Microsoft.Compute/virtualMachines/myVM?api-version=2018-06-01

标头:Content-Type:application/json 授权:Bearer 'eyJ0eXAimtpZCI....'(从上述 API 的 try it 功能中获得令牌)

身体:

{
'location': 'westus',
'properties': {
'hardwareProfile': {
'vmSize': 'Standard_D1_v2'
},
'storageProfile': {
'imageReference': {
'sku': '2016-Datacenter',
'publisher': 'MicrosoftWindowsServer',
'version': 'latest',
'offer': 'WindowsServer'
},
'osDisk': {
'caching': 'ReadWrite',
'managedDisk': {
'storageAccountType': 'Standard_LRS'
},
'name': 'myVMosdisk',
'createOption': 'FromImage'
}
},
'osProfile': {
 "adminUsername": "Demo1",
 "computerName": "myVM",
 "adminPassword": "Demo1Demo1Demo1"
}
,
'networkProfile': {
'networkInterfaces': [
{
'id': '/subscriptions/40fbe15/resourceGroups/sym/providers/Microsoft.Network/networkInterfaces/deletethis374',
'properties': {
'primary': true
}
}
]
}
}
}

标签: azureazure-virtual-machine

解决方案


在这种情况下,错误是由于 VM 及其 NIC 必须位于同一区域中。未找到错误提示,因为它正在寻找 ID 和区域的组合。


推荐阅读