"name" under "networkInterfaceConfigurations" in create virtual machine request is used as prefix

valerijf 25 Reputation points
2024-02-09T12:05:51.0866667+00:00

When creating a Virtual Machine in Azure using the REST API[1], the value of the name property under networkInterfaceConfigurations is used as a prefix and not the absolute name. Here's a request and the response to it as logged by the Azure Java SDK:

Feb 09, 2024 11:40:14 AM com.azure.core.util.logging.LoggingEventBuilder performLogging
INFO: {"az.sdk.message":"HTTP request","method":"PUT","url":"https://management.azure.com/subscriptions/REDACTED/resourceGroups/dev.eastus-az1-tenant/providers/Microsoft.Compute/virtualMachines/h11-dev-eastus-az1?api-version=2023-09-01","tryCount":1,"Date":"Fri, 09 Feb 2024 10:40:13 GMT","Content-Length":"2382","x-ms-return-client-request-id":"true","Content-Type":"application/json","x-ms-client-request-id":"6f50ccbc-a3bb-4160-b6a0-48c8920bb40d","Accept":"application/json","User-Agent":"azsdk-java-com.azure.resourcemanager.compute/2.35.0 (17.0.3; Linux; 5.15.0-89-generic)","redactedHeaders":"Authorization","contentLength":2382,"body":"{\"location\":\"eastus\",\"properties\":{\"hardwareProfile\":{\"vmSize\":\"Standard_B1ms\"},\"storageProfile\":{\"imageReference\":{\"id\":\"/subscriptions/REDACTED/resourceGroups/vm-images/providers/Microsoft.Compute/galleries/vespa_almalinux_8/images/x86_64/versions/latest\"},\"osDisk\":{\"name\":\"h11-dev-eastus-az1-disk-root\",\"createOption\":\"FromImage\",\"diskSizeGB\":30,\"managedDisk\":{\"diskEncryptionSet\":{\"id\":\"/subscriptions/REDACTED/resourceGroups/dev.eastus-az1/providers/Microsoft.Compute/diskEncryptionSets/disk-encryption\"}},\"deleteOption\":\"Delete\"},\"dataDisks\":[{\"lun\":0,\"name\":\"h11-dev-eastus-az1-disk-data\",\"createOption\":\"Empty\",\"diskSizeGB\":100,\"deleteOption\":\"Delete\"}]},\"osProfile\":{\"computerName\":\"h11-dev-eastus-az1\",\"adminUsername\":\"vespa\",\"adminPassword\":\"bdNqXLkT40ZmjR8p-VmsgoiWCPqL2AaGdEsDfttejkLvTI09EDLuk8OgzKcu1diFFSBIsw\",\"linuxConfiguration\":{}},\"networkProfile\":{\"networkApiVersion\":\"2020-11-01\",\"networkInterfaceConfigurations\":[{\"name\":\"h11-dev-eastus-az1-nic\",\"properties\":{\"deleteOption\":\"Delete\",\"ipConfigurations\":[{\"name\":\"h11-dev-eastus-az1-ip4c-0\",\"properties\":{\"subnet\":{\"id\":\"/subscriptions/REDACTED/resourceGroups/dev.eastus-az1/providers/Microsoft.Network/virtualNetworks/network/subnets/subnet-tenant\"},\"primary\":true,\"publicIPAddressConfiguration\":{\"name\":\"h11-dev-eastus-az1-pip4-0\",\"properties\":{\"publicIPAddressVersion\":\"IPv4\",\"publicIPAllocationMethod\":\"Static\"},\"sku\":{\"name\":\"Standard\"}},\"privateIPAddressVersion\":\"IPv4\"}},{\"name\":\"h11-dev-eastus-az1-ip4c-1\",\"properties\":{\"subnet\":{\"id\":\"/subscriptions/REDACTED/resourceGroups/dev.eastus-az1/providers/Microsoft.Network/virtualNetworks/network/subnets/subnet-tenant\"},\"primary\":false,\"publicIPAddressConfiguration\":{\"name\":\"h11-dev-eastus-az1-pip4-1\",\"properties\":{\"publicIPAddressVersion\":\"IPv4\",\"publicIPAllocationMethod\":\"Static\"},\"sku\":{\"name\":\"Standard\"}},\"privateIPAddressVersion\":\"IPv4\"}}]}}]},\"securityProfile\":{\"encryptionAtHost\":true},\"userData\":\"IyEvYmluL3NoCmVjaG8gIlByb3Zpc2lvbmVkIGZyb20gQXp1cmVDb21wdXRlQ2xpZW50VGVzdCIgfCB0ZWUgL3Jvb3Qvb3V0cHV0LnR4dAo=\"},\"identity\":{\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"/subscriptions/REDACTED/resourceGroups/system/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id-tenant\":{}}},\"zones\":[\"3\"]}"}
Feb 09, 2024 11:40:18 AM com.azure.core.util.logging.LoggingEventBuilder performLogging
INFO: {"az.sdk.message":"HTTP response","contentLength":"2894","statusCode":201,"url":"https://management.azure.com/subscriptions/REDACTED/resourceGroups/dev.eastus-az1-tenant/providers/Microsoft.Compute/virtualMachines/h11-dev-eastus-az1?api-version=2023-09-01","durationMs":3790,"Date":"Fri, 09 Feb 2024 10:40:17 GMT","Server":"Microsoft-HTTPAPI/2.0,Microsoft-HTTPAPI/2.0","Content-Length":"2894","Expires":"-1","Retry-After":"10","Pragma":"no-cache","Content-Type":"application/json; charset=utf-8","Cache-Control":"no-cache","x-ms-request-id":"091d061e-63dd-4e0f-a11a-b7c11104098e","x-ms-client-request-id":"6f50ccbc-a3bb-4160-b6a0-48c8920bb40d","redactedHeaders":"azure-asyncnotification,x-ms-ratelimit-remaining-subscription-writes,x-ms-correlation-request-id,Strict-Transport-Security,X-Content-Type-Options,x-ms-routing-request-id,x-ms-ratelimit-remaining-resource,Azure-AsyncOperation","body":"{\r\n  \"name\": \"h11-dev-eastus-az1\",\r\n  \"id\": \"/subscriptions/REDACTED/resourceGroups/dev.eastus-az1-tenant/providers/Microsoft.Compute/virtualMachines/h11-dev-eastus-az1\",\r\n  \"type\": \"Microsoft.Compute/virtualMachines\",\r\n  \"location\": \"eastus\",\r\n  \"identity\": {\r\n    \"type\": \"UserAssigned\",\r\n    \"userAssignedIdentities\": {\r\n      \"/subscriptions/REDACTED/resourceGroups/system/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id-tenant\": {}\r\n    }\r\n  },\r\n  \"properties\": {\r\n    \"hardwareProfile\": {\r\n      \"vmSize\": \"Standard_B1ms\"\r\n    },\r\n    \"provisioningState\": \"Creating\",\r\n    \"vmId\": \"6efca292-4b7a-4e9b-b0c6-ac87c8ad0d69\",\r\n    \"storageProfile\": {\r\n      \"imageReference\": {\r\n        \"id\": \"/subscriptions/REDACTED/resourceGroups/vm-images/providers/Microsoft.Compute/galleries/vespa_almalinux_8/images/x86_64/versions/latest\",\r\n        \"exactVersion\": \"8.20240208.142019\"\r\n      },\r\n      \"osDisk\": {\r\n        \"osType\": \"Linux\",\r\n        \"name\": \"h11-dev-eastus-az1-disk-root\",\r\n        \"createOption\": \"FromImage\",\r\n        \"caching\": \"ReadWrite\",\r\n        \"managedDisk\": {\r\n          \"diskEncryptionSet\": {\r\n            \"id\": \"/subscriptions/REDACTED/resourceGroups/dev.eastus-az1/providers/Microsoft.Compute/diskEncryptionSets/disk-encryption\"\r\n          },\r\n          \"storageAccountType\": \"Premium_LRS\"\r\n        },\r\n        \"deleteOption\": \"Delete\",\r\n        \"diskSizeGB\": 30\r\n      },\r\n      \"dataDisks\": [\r\n        {\r\n          \"lun\": 0,\r\n          \"name\": \"h11-dev-eastus-az1-disk-data\",\r\n          \"createOption\": \"Empty\",\r\n          \"caching\": \"None\",\r\n          \"managedDisk\": {\r\n            \"storageAccountType\": \"Premium_LRS\"\r\n          },\r\n          \"deleteOption\": \"Delete\",\r\n          \"diskSizeGB\": 100,\r\n          \"toBeDetached\": false\r\n        }\r\n      ],\r\n      \"diskControllerType\": \"SCSI\"\r\n    },\r\n    \"osProfile\": {\r\n      \"computerName\": \"h11-dev-eastus-az1\",\r\n      \"adminUsername\": \"vespa\",\r\n      \"linuxConfiguration\": {\r\n        \"disablePasswordAuthentication\": false,\r\n        \"provisionVMAgent\": true,\r\n        \"patchSettings\": {\r\n          \"patchMode\": \"ImageDefault\",\r\n          \"assessmentMode\": \"ImageDefault\"\r\n        },\r\n        \"enableVMAgentPlatformUpdates\": false\r\n      },\r\n      \"secrets\": [],\r\n      \"allowExtensionOperations\": true,\r\n      \"requireGuestProvisionSignal\": true\r\n    },\r\n    \"securityProfile\": {\r\n      \"encryptionAtHost\": true\r\n    },\r\n    \"networkProfile\": {\"networkInterfaces\":[{\"id\":\"/subscriptions/REDACTED/resourceGroups/dev.eastus-az1-tenant/providers/Microsoft.Network/networkInterfaces/h11-dev-eastus-az1-nic-8089b83e\",\"properties\":{\"primary\":false,\"deleteOption\":\"Delete\"}}]},\r\n    \"timeCreated\": \"2024-02-09T10:40:16.6430377+00:00\"\r\n  },\r\n  \"zones\": [\r\n    \"3\"\r\n  ]\r\n}"}

The requested networkInterfaceConfigurations name is h11-dev-eastus-az1-nic, but the returned ID under networkInterfaces is /subscriptions/REDACTED/resourceGroups/dev.eastus-az1-tenant/providers/Microsoft.Network/networkInterfaces/h11-dev-eastus-az1-nic-8089b83e. Not included in the response are the public IPs, which also got the -8089b83e suffix. The osDisk and dataDisks name is handled correctly. [1] https://learn.microsoft.com/en-us/rest/api/compute/virtual-machines/create-or-update?view=rest-compute-2023-10-02&tabs=HTTP

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,876 questions
{count} votes

Accepted answer
  1. kobulloc-MSFT 26,321 Reputation points Microsoft Employee
    2024-02-16T08:20:45.4+00:00

    Hello, @valerijf ! We received your feedback and want to make sure your question is answered.

    Why is "name" under "networkInterfaceConfigurations" in create virtual machine request is used as prefix?

    While I agree that it seems to be automatically created by Azure to avoid a conflict, I'm not able to determine what in the documentation outlines that this is expected:

    To determine exactly what is causing this, please email the following to AzCommunity@microsoft.com and we'll get back to you promptly:

    • Subject: "Attn: kobulloc - NIC suffix with REST API"
    • Email body: Your Subscription ID
    • Email body: A link to this thread so we can validate and expedite the request

    If you don't receive a response within 24 hours, please reply to the thread so we can investigate.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Luis Arias 6,796 Reputation points
    2024-02-12T11:02:34.2+00:00

    Hi valerijf ,
    It appears that the Azure REST API is using the name property under networkInterfaceConfigurations as a prefix, appending a suffix to create a unique identifier for the network interface.

    The suffix -8089b83e seems to be automatically generated by Azure, likely to ensure the uniqueness of the network interface within the scope of the resource group. This is a common practice in cloud services to avoid naming conflicts when resources are programmatically created. The osDisk and dataDisks names are handled correctly because these resources have a different lifecycle and management practices compared to network interfaces. If you want to have control over the exact names of your network interfaces, you might consider creating them separately using the Network Interface API, and then referencing them when creating the virtual machine.
    Additional reference:

    Let me know if this help you,

    Luis

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.