Azure naming tool API call is failing

Manga, Shiva 0 Reputation points
2023-08-07T20:52:15.17+00:00
I am trying to generate the Azure Resource Name using Azure Naming tool API. The tool is deployed into Linux VM from CloudAdoptionFramework/ready/AzNamingTool at master · microsoft/CloudAdoptionFramework (github.com)Generating the names manually with the tool works good. But when i try to generate the name using the API, it gives error.

Request body ResourceNameRequest (json) - Resource Name Request data{ 'ResourceEnvironment': 'prd', 'ResourceInstance': '2', 'ResourceType': 'vm' } I get an error saying ResourceType field required. I tried changing the resource type to microsft.compute/virtualmachines , compute, virtual machine but did not work.

I observed the same issue with resource types like vmss, api, app, by referring the below document.Abbreviation examples for Azure resources - Cloud Adoption Framework | Microsoft Learn

Unsuccessful call :

------------------
Request body


{ 

  "request": [ 

    { 

      "resourceType": "vm", 

      "resourceUnitDept": "sud", 

      "resourceProjAppSvc": "spa", 

      "resourceFunction": "func", 

      "resourceEnvironment": "dev", 

      "resourceLocation": "ac", 

      "resourceInstance": "1"       

    }, 

    { 

      "resourceId": 0, 

      "createdBy": "string" 

    } 

  ] 

}

Server response

Error: Bad Request


{   "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",   "title": "One or more validation errors occurred.",   "status": 400,   "traceId": "00-537c088c754bd9824432d838b540bf35-5fa99721639c3c36-00",   "errors": {     "ResourceType": [       "The ResourceType field is required."     ]   } }

Successful call :

==========

Request body :


{ 

	  "ResourceEnvironment": "prd", 

	  "ResourceInstance": "6", 

	  "ResourceLocation": "eu", 

	  "ResourceProjAppSvc": "spa", 

	  "ResourceType": "redis" 

	}

Response body :

==========

{
  "resourceName": "redis-spa-prd-eu-6",
  "message": "",
  "success": true,
  "resourceNameDetails": {
    "id": 7,
    "createdOn": "2023-08-02T13:32:18.6596776+00:00",
    "resourceName": "redis-spa-prd-eu-6",
    "resourceTypeName": "Cache/Redis",
    "components": [
      [
        "ResourceType",
        "redis"
      ],
      [
        "ResourceProjAppSvc",
        "spa"
      ],
      [
        "ResourceEnvironment",
        "prd"
      ],
      [
        "ResourceLocation",
        "eu"
      ],
      [
        "ResourceInstance",
        "6"
      ]
    ],
    "user": "API"
  }
}

Tried changing the case of the ResourceType field, but it still didn't work.

I'm struggling to locate the API documentation for the Azure Naming tool. Could someone please point me in the right direction or provide a link if available? Your assistance would be greatly appreciated.

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

1 answer

Sort by: Most helpful
  1. vipullag-MSFT 26,476 Reputation points
    2023-08-08T06:25:45.7966667+00:00

    Hello Manga, Shiva

    Welcome to Microsoft Q&A Platform, thanks for posting your query here.

    In your unsuccessful call, it looks like you included the "resourceType" field, but it may not have been in the correct format. The correct format for the "resourceType" field is the name of the Azure resource type, such as "Microsoft.Compute/virtualMachines" for a virtual machine.

    Here's an example of a request body that includes the "resourceType" field in the correct format:

    {
      "request": [
        {
          "resourceType": "Microsoft.Compute/virtualMachines",
          "resourceUnitDept": "sud",
          "resourceProjAppSvc": "spa",
          "resourceFunction": "func",
          "resourceEnvironment": "dev",
          "resourceLocation": "ac",
          "resourceInstance": "1"
        },
        {
          "resourceId": 0,
          "createdBy": "string"
        }
      ]
    }
    

    Please make sure that you are using the correct format for the "resourceType" field and try again.

    Hope this helps.

    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.