Generating names for resource that have Insatnce set to optional fails in Bad Request Instance required.
Using postman I would do a GET on /api/ResourceNamingRequests/RequestName with request body set to
{ "resourceEnvironment": "prd", "resourceProjAppSvc": "spa", "resourceType:" "bp" }
Response is { "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1", "title": "One or more validation errors occurred.", "status": 400, "traceId": "00-ca7dc542fa9af4431918416fc8d1b7d8-d54f1483039b047d-00", "errors": { "ResourceInstance": [ "The ResourceInstance field is required." ] } }
Fixed it by changing in public class ResourceNameRequest
current line of code
public string ResourceInstance { get; set; }
fixed line of code
public string ResourceInstance? { get; set; }
now I get this for a reponse
{ "resourceName": "bp-spa-prd", "message": "", "success": true }
Hi @judyanndixon, Thank you for your feedback. The bug you noted applies to previous version of the tool. This has been updated in the new version in the Cloud Adoption Framework repo:
https://github.com/microsoft/CloudAdoptionFramework/tree/master/ready/AzNamingTool
Please be sure to open all issues in that repo, as this one is not monitored regularly.
In the "new" repo, the new ResourceNameRequestSimple class has the ResourceInstance as optional. This is the class that the /api/ResourceNameRequests/RequestName function is currently calling.
https://github.com/microsoft/CloudAdoptionFramework/blob/master/ready/AzNamingTool/Models/ResourceNameRequestSimple.cs
namespace AzureNamingTool.Models { public class ResourceNameRequest { public string? ResourceEnvironment { get; set; } public string? ResourceFunction { get; set; } public string ResourceInstance { get; set; } public string? ResourceLocation { get; set; } public string? ResourceOrg { get; set; } public string? ResourceProjAppSvc { get; set; } public string ResourceType { get; set; } public string? ResourceUnitDept { get; set; } } }
Note, the above class is now used for "most" name requests, as the previous version required full component definition. Additionally, we will be renaming the class file names to align with this new structure in a future update.
- Bryan
Looks like this class also needs a tweak as well. I took this copy from the "new" repo you shared with me from above. Thanks for letting me know about it. I'll switch over to that one. public class ResourceNameRequestWithComponents { public ResourceDelimiter ResourceDelimiter { get; set; } public ResourceEnvironment? ResourceEnvironment { get; set; } public ResourceFunction? ResourceFunction { get; set; } public string ResourceInstance { get; set; } public ResourceLocation? ResourceLocation { get; set; } public ResourceOrg? ResourceOrg { get; set; } public ResourceProjAppSvc? ResourceProjAppSvc { get; set; } public ResourceType ResourceType { get; set; } public ResourceUnitDept? ResourceUnitDept { get; set; } }
Yeah, we have that update staged for a future release, as well. Thank you for the feedback!
-Bryan