Cannot provision Virtual Machine in Azure- Subnet reference is required

Problem: Cannot provision Virtual Machine in Azure - Subnet reference is required

Expected outcome: Provision host on Azure using DHCP from Azure.

Foreman and Proxy versions: 3.11.2

Foreman and Proxy plugin versions: rubygem-foreman_azure_rm-2.3.0-1.fm3_11.el9.noarch

Distribution and version: RHEL 9.4
I don’t have any DHCP proxy installed nor configured.
I want to use DHCP on Azure.

The error is:
Failed to create a compute Azure West Europe - Linux Test (Azure Resource Manager) instance CENSORED: { “message”: “MsRestAzure::AzureOperationError: SubnetIsRequired: Subnet reference is required for ipconfiguration /subscriptions/CENSORED/resourceGroups/CENSORED/providers/Microsoft.Network/networkInterfaces/CENSORED-nic0/ipConfigurations/CENSORED-nic0.”, “request”: { “base_uri”: “https://management.azure.com/”, “path_template”: “subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkInterfaces/{networkInterfaceName}”, “method”: “put”, “path_params”: { “resourceGroupName”: “CENSORED”, “networkInterfaceName”: “CENSORED-nic0”, “subscriptionId”: “CENSORED” }, “skip_encoding_path_params”: null, “query_params”: { “api-version”: “2020-08-01” }, “skip_encoding_query_params”: null, “headers”: { “Content-Type”: “application/json; charset=utf-8”, “Accept”: “application/json”, “accept-language”: “en-US”, “x-ms-client-request-id”: “6b4052d2-6f3b-4e89-bc4a-2f8ea0d52a3e” }, “body”: “{"location":"westeurope","properties":{"ipConfigurations":[{"properties":{"privateIPAllocationMethod":"Dynamic"},"name":"CENSORED-nic0"}]}}”, “middlewares”: [ [ “MsRest::RetryPolicyMiddleware”, { “times”: 3, “retry”: 0.02 } ], [ “cookie_jar” ] ], “log”: null }, “response”: { “body”: “{"error":{"code":"SubnetIsRequired","message":"Subnet reference is required for ipconfiguration /subscriptions/CENSORED/resourceGroups/CENSORED/providers/Microsoft.Network/networkInterfaces/CENSORED-nic0/ipConfigurations/CENSORED-nic0.","details":}}”, “headers”: { “Cache-Control”: “no-cache”, “Pragma”: “no-cache”, “Content-Length”: “305”, “Content-Type”: “application/json; charset=utf-8”, “Expires”: “-1”, “x-ms-request-id”: “CENSORED”, “x-ms-correlation-request-id”: “CENSORED”, “x-ms-arm-service-request-id”: “CENSORED”, “Strict-Transport-Security”: “max-age=31536000; includeSubDomains”, “x-ms-ratelimit-remaining-subscription-writes”: “199”, “x-ms-ratelimit-remaining-subscription-global-writes”: “2999”, “x-ms-routing-request-id”: “WESTEUROPE:20241021T142527Z:CENSORED”, “X-Content-Type-Options”: “nosniff”, “X-Cache”: “CONFIG_NOCACHE”, “X-MSEdge-Ref”: “Ref A: D6396454D6AF44F8BF28A560A416A8A3 Ref B: DB3EDGE2806 Ref C: 2024-10-21T14:25:27Z”, “Date”: “Mon, 21 Oct 2024 14:25:26 GMT” }, “status”: 400 } }

I have empty Azure Subnet drop down menu in Azure Resource Manager section under Interface options while creating new host. Subnets in Azure exists.

Previously I had this working but now I also have an empty subnet drop down in that position. I’m not using DHCP but still now reading the subnet in that drop down.

Turns out I hadn’t granted the service principal enough permissions in Azure. I’d given Virtual Machine Contributor but just Contributor for the relevant resource group works. You may be able to get away with less. Maybe this could be something that’s added to the docs.