Azure DNS Zones REST API Returning Bad Request Error

Lakshmipathi Kakarla 1 Reputation point
2021-02-02T09:39:19.023+00:00

Hello team,

Please review below issue and provide input to resolve the same.

I tried to list Azure DNS Zones available in a subscription using REST API as mentioned below

https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Network/dnszones?api-version=2018-05-01

Returned Error:
Bad Request({"code":"BadRequest","message":"The specified subscription {subscriptionId} does not exist"})

I provided valid subscription id.

OS version: Ubuntu 18.04

Azure CLI Version:

$ az version

    {
      "azure-cli": "2.18.0",
      "azure-cli-core": "2.18.0",
      "azure-cli-telemetry": "1.0.6",
      "extensions": {
        "account": "0.2.1",
        "resource-graph": "1.1.0"
      }
    }
Azure DNS
Azure DNS
An Azure service that enables hosting Domain Name System (DNS) domains in Azure.
634 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. JamesTran-MSFT 36,541 Reputation points Microsoft Employee
    2021-02-03T21:31:25.023+00:00

    @Lakshmipathi Kakarla
    Thank you for your detailed post!

    I tested this out within my lab environment and was able to successfully call the REST API. When it comes to your specific error message, can you make sure that you're using the correct SubscriptionID.

    Error Message:
    Bad Request({"code":"BadRequest","message":"The specified subscription {subscriptionId} does not exist"})

    Next Steps:
    Confirm you're using the correct SubscriptionID

    • Navigate to your Azure Portal -> Navigate to Cost Management + Billing -> Subscriptions -> Copy the SubscriptionID you're trying to use.
      63638-subid.gif

    Once you have the correct SubscriptionID, you can try re-running the REST API call:

    GET https://management.azure.com/subscriptions/<SubscriptionID>/providers/Microsoft.Network/dnszones?api-version=2018-05-01  
    

    63618-getdnszoneslist.gif

    If you have any other questions, please let me know.
    Thank you for your time and patience throughout this issue.

    ----------

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    1 person found this answer helpful.

  2. Erik van Noorden 6 Reputation points
    2021-04-23T15:03:22.59+00:00

    i got the same error.
    turns out the 'Microsoft.Network' provider was not registered in the subscription (Azure Portal > Subscriptions > Resource providers > Microsoft.Network --> register)

    but the error is still weird as other requests to the same provider (eg. providers/Microsoft.Network/virtualNetworks?api-version=2020-07-01) returned a 200 even if no resources exist in the subscription

    1 person found this answer helpful.
    0 comments No comments