azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

az vm create returns an error when NIC in other ResourceGroup is specified for '--nics'

Open thiruma0203 opened this issue 9 years ago • 1 comments

  • Consider VNET and NIC resources are already created on other Resrouce Group (say RGVNET).
  • Then, create a VM in different Resource Group (RGVM) with command like below;

az vm create -g **RGVM** -n NewVM --nics "/subscriptions/xxxxxxxxxxxx/resourceGroups/**RGVNET**/providers/Microsoft.Network/networkInterfaces/ExistingNIC" --attach-os-disk --os-type Linux --debug

  • Command returns with following error.

The Resource 'Microsoft.Network/networkInterfaces/ExistingNIC' under resource group 'RGVM' was not found.

  • As far as looking into --debug log, az is making a query to Resource Group RGVM rather than RGVNET for getting info of ExisitingNIC.

requests.packages.urllib3.connectionpool : Starting new HTTPS connection (1): management.azure.com requests.packages.urllib3.connectionpool : https://management.azure.com:443 "GET /subscriptions/xxxxxxxxxx/resourceGroups/RGVM/providers/Microsoft.Network/networkInterfaces/ExsistingNIC ?api-version=2016-09-01 HTTP/1.1" 404 163 msrest.http_logger : Response status: 404 msrest.http_logger : Response headers: msrest.http_logger : 'Cache-Control': 'no-cache' msrest.http_logger : 'Pragma': 'no-cache' msrest.http_logger : 'Content-Type': 'application/json; charset=utf-8' msrest.http_logger : 'Expires': '-1' msrest.http_logger : 'x-ms-failure-cause': 'gateway' msrest.http_logger : 'x-ms-request-id': '6f39598c-4395-41e7-a9d4-ee9d18115442' msrest.http_logger : 'x-ms-correlation-request-id': '6f39598c-4395-41e7-a9d4-ee9d18115442' msrest.http_logger : 'x-ms-routing-request-id': 'CENTRALUS:20170308T105500Z:6f39598c-4395-41e7-a9d4-ee9d18115442' msrest.http_logger : 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' msrest.http_logger : 'Date': 'Wed, 08 Mar 2017 10:55:00 GMT' msrest.http_logger : 'Content-Length': '163' msrest.http_logger : Response content: msrest.http_logger : b'{"error":{"code":"ResourceNotFound","message":"The Resource 'Microsoft.Network/networkInterfaces/ExistingNIC' under resource group 'RGVM' was not found."}}' msrest.exceptions : The Resource 'Microsoft.Network/networkInterfaces/ExistingNIC' under resource group 'RGVM' was not found.

thiruma0203 avatar Mar 08 '17 11:03 thiruma0203

In this case, the VM is actually created with the correct reference to the other resource group's NIC. The command throws an error because after the deployment, it essentially make a call like "az vm show -g {} -n {} -d" and it seems this part (to get the details) assumes the NIC is in the same resource group, which is not correct. cc/ @yugangw-msft

tjprescott avatar Mar 08 '17 18:03 tjprescott