Azure / autorest.csharp

Extension for AutoRest (https://github.com/Azure/autorest) that generates C# code
MIT License
143 stars 165 forks source link

Azure-rest-api-specs PR SDK azure-sdk-for-net-track2 task failing with "Cannot determine a resource class name for resource" #3174

Open Rusalunk opened 1 year ago

Rusalunk commented 1 year ago

Describe the issue or request Azure-rest-api-specs PR SDK azure-sdk-for-net-track2 task failing with below error:

[Invoke-GenerateAndBuildV2.ps1] Exception: Cannot determine a resource class name for resource with the request path: {}, please assign a valid resource name in request-path-to-resource-name section.

Build : https://dev.azure.com/azure-sdk/internal/_build/results?buildId=2211811&view=logs&j=03afb3bb-7296-55ad-aa07-ceee610c73b2&t=0f320c29-1c90-5304-d2d3-c58a6bb76437

PR : https://github.com/Azure/azure-rest-api-specs/pull/22766

Can I get the help in understanding the issue, as we have created the resource name classes with existing similar paths in the past with no issue.

Describe your ideas for solutions Please describe how you think a change or changes might work. Consider how these changes might work for multiple services.

Add labels As appropriate, select a label to describe how hard the issue is to work around or how hard it would be to do without a particular feature that could help make it easier. These labels start with "workaround".

Also select a label that describes how many instances of the workaround you would have to do without the bug being fixed or feature implemented. These labels start with "instances".

These labels will help priority bug fixes and feature requests.

If this bug or feature request is for older versions of autorest, please remove the v3 label and add the v2 label as appropriate.

ArcturusZhang commented 1 year ago

Hi @Rusalunk this happens because the generator cannot determine resource name for some of the resources, it is explicitly asking for suggestions. To solve this, we need to add some configurations into the request-path-to-resource-name mapping from its path to the resource name. In your case, you need to add a resource name for this resource /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{vmName}/providers/Microsoft.GuestConfiguration/guestConfigurationAssignments/{guestConfigurationAssignmentName}