0
votes

Linking a Network Interface while creating a VM (using https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/createorupdate#create_a_vm_with_password_authentication.) in the same resource group as that of the Network interface throws this error (I am the owner for the Virtual Network Subnet which is attached to the Network Interface):

Error:

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

Request details:

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

Headers: Content-Type:application/json Authorization: Bearer 'eyJ0eXAimtpZCI....' (got the token from try it feature of the above mentioned API)

Body:

{
'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
}
}
]
}
}
}
1
can you confirm this NIC exists, is in the same subscription and region (as the VM is)?4c74356b41
The nic was not in the same region. Thanks!mangesh

1 Answers

1
votes

in this case the error was due to the fact that the VM and its NIC have to be in the same region. Not found error hints at that, because its looking for a combination of ID and region.