microsoft / CloudAdoptionFramework

Code samples and extended documentation to support the guidance provided in the Microsoft Cloud Adoption Framework
https://aka.ms/CAF
Creative Commons Attribution 4.0 International
854 stars 614 forks source link

AzNamingTool - Unable to generate name using rest api for optional custom component #161

Closed ciprianglg closed 1 year ago

ciprianglg commented 1 year ago

If you have at least two custom components defined, from which at least one is optional, you are not able to generate name using rest api. From the interface generating name, it is working.

curl -X 'POST' \
  'https://app-apl212547-002-we-dev.azurewebsites.net/api/ResourceNamingRequests/RequestName' \
  -H 'accept: */*' \
  -H 'APIKey: YYYYYYYYYYYYYYY' \
  -H 'Content-Type: application/json' \
  -d '{
  "resourceType": "rg",
  "customComponents": {
   "ProjId": "test"
  },
  "resourceInstance": "001",
  "resourceLocation": "we",
  "resourceEnvironment": "dev"
}'

Error:

{
  "resourceName": "***RESOURCE NAME NOT GENERATED***",
  "message": "You must supply the required components. Scope value was not provided. ",
  "success": false
}

Scope is a custom free text component, and is optional.

If you include it, it is working:

curl -X 'POST' \
  'https://app-apl212547-002-we-dev.azurewebsites.net/api/ResourceNamingRequests/RequestName' \
  -H 'accept: */*' \
  -H 'APIKey: YYYYY' \
  -H 'Content-Type: application/json' \
  -d '{
  "resourceType": "rg",
  "customComponents": {
   "ProjId": "test",
   "Scope": "scope"
  },
  "resourceInstance": "001",
  "resourceLocation": "we",
  "resourceEnvironment": "dev"
}'
{
  "resourceName": "rg-test-001-scope-we-dev",
  "message": "",
  "success": true
}

I have attached global config for easy reproducing. globalconfig.zip

BryanSoltis commented 1 year ago

Thank you @ciprianglg!

I've found the issue and this will be included in the next release.

-Bryan

ciprianglg commented 1 year ago

@BryanSoltis Thanks for this.