Creating NetworkInterface in with Azure REST API results in InvalidRequestFormat without details

204 views Asked by At

I'm trying to create a NetworkInterface with the body of the request looking like this:

{
  "location": "North Europe",
  "properties": {
    "ipConfigurations": [
      {
        "properties": {
          "privateIPAddress": "10.10.1.4",
          "subnet": {
            "id": "/subscriptions/<foo>/resourceGroups/<bar>/providers/Microsoft.Network/virtualNetworks/<funk>/subnets/<blah>"
          }
        }
      }
    ],
    "networkSecurityGroup": {
      "id": "/subscriptions/<foo>/resourceGroups/<bar>/providers/Microsoft.Network/networkSecurityGroups/<baz>"
    }
  }
}

However, this results in an error:

{
  "error": {
    "code": "InvalidRequestFormat",
    "message": "Cannot parse the request.",
    "details": []
  }
}

This is especially surprising because the error messages usually contain helpful details.

Any suggestions on what I might be getting wrong here?

1

There are 1 answers

1
Nancy On BEST ANSWER

Here is a working sample on my side. After my validation, we must specify the "name": "ipconfig1" under "ipConfigurations". If you do not specify the "privateIPAllocationMethod": "Static", it will dynamically be assigned the IP address for you.

 {      
            "location": "westus2",     
            "properties": {
                "ipConfigurations": [
                    {
                        "name": "ipconfig1",
                        "properties": {
                            "privateIPAddress": "172.29.0.4",
                            "privateIPAllocationMethod": "Static", 
                            "subnet": {
                                "id": "/subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.Network/virtualNetworks/vnet/subnets/<default>"
                            }           
                        }
                    }
                ],

                "networkSecurityGroup": {
                    "id": "/subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.Network/networkSecurityGroups/<nsg>"
                }
            }
        }

Result

enter image description here