Azure / Azure/typespec-azure

resolveArmResources resourceName can ignore TCGC client-name overrides

Open
#5,217 3 comments 0 reactions 1 assignee Assigned to @markcowl View on GitHub
design:needed lib:azure-resource-manager triaged:core
Dominant language
TypeScript
Stars
27
Forks
90
Avg merge
1d 22h
Merged PRs (30d)
156

Description

## Summary

When `resolveArmResources` is used by downstream SDK emitters, `ResolvedResource.resourceName` can disagree with the resource model name produced by TCGC when the model has a C# `@clientName` override and there is no explicit ARM resource-name override.

This causes downstream generated resource class names to change even though the ARM resource set is unchanged.

## Observed in validation

While validating Azure/typespec-azure#4851 in Azure/azure-sdk-for-net provisioning generation, CDN kept the same 15 ARM resource types, but 13 generated provisioning resource classes were renamed.

Examples from the saved `tspCodeModel.json` input:

| ARM resource type | TCGC model name | `resolveArmResources` projection `resourceName` |
| --- | --- | --- |
| `Microsoft.Cdn/profiles/customDomains` | `FrontDoorCustomDomain` | `AFDDomain` |
| `Microsoft.Cdn/profiles/afdEndpoints` | `FrontDoorEndpoint` | `AFDEndpoint` |
| `Microsoft.Cdn/profiles/endpoints` | `CdnEndpoint` | `Endpoint` |
| `Microsoft.Cdn/profiles/endpoints/origins` | `CdnOrigin` | `Origin` |
| `Microsoft.Cdn/profiles/originGroups` | `FrontDoorOriginGroup` | `AFDOriginGroup` |
| `Microsoft.Cdn/profiles/ruleSets/rules` | `FrontDoorRule` | `Rule` |

The corresponding TCGC models have `Azure.ResourceManager.@hasClientNameOverride`, so TCGC is preserving explicit C# names. `resolveArmResources` appears to fall back to the TypeSpec model/resource name instead.

## Expected behavior

For resource naming, the behavior should align with the legacy detection path:

1. Honor explicit resource-name override first.
2. Otherwise use the resource model's SDK-facing name after TCGC/client-name transformation.

## Actual behavior

`resolveArmResources` appears to do the first step, but for fallback naming it uses the TypeSpec resource/model name. Since `typespec-azure-resource-manager` does not depend on TCGC, it does not see the TCGC-renamed model name.

## Why this matters

Downstream emitters that use `ResolvedResource.resourceName` for SDK resource class names can produce large rename-only API churn. In CDN, no ARM resources were added or deleted by resource type; the churn was caused by resource-name disagreement.

## Possible direction

Either `resolveArmResources` should expose enough information for downstream emitters to match the resolved resource back to the TCGC model and use the SDK-facing model name, or the API/docs should clarify that `resourceName` is a TypeSpec/ARM name and not an SDK-facing resource class name.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.