Skip to content

Migrate resource manager resources generation to TypeSpec - #50111

Open
Weidong Xu (weidongxu-microsoft) wants to merge 39 commits into
Azure:mainfrom
weidongxu-microsoft:issue-49803-resources-typespec
Open

Migrate resource manager resources generation to TypeSpec#50111
Weidong Xu (weidongxu-microsoft) wants to merge 39 commits into
Azure:mainfrom
weidongxu-microsoft:issue-49803-resources-typespec

Conversation

@weidongxu-microsoft

Copy link
Copy Markdown
Member

Summary

  • Migrate the combined Resource Manager resources library from Swagger generation to the selected TypeSpec projects.
  • Preserve the existing public API and handwritten integration through TypeSpec and Java customizations.
  • Prevent SDK automation from deleting outputs belonging to other projects in the combined package.
  • Update playback assets and reviewed RevAPI suppressions.

Fixes #49803.

Testing

  • mvn -f sdk/resources/azure-resourcemanager-resources/pom.xml test
    • 91 tests run, 0 failures, 0 errors, 7 skipped.
  • RevAPI comparison against 2.54.2 completes without API compatibility failures.

Regenerate the features, locks, and changes Swagger projects while removing generated code owned by projects migrating to TypeSpec.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Remove generated policy samples that are no longer owned by the retained Swagger projects.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Replace the AutoRest deletion marker in files owned by the retained Swagger projects so TypeSpec regeneration does not remove them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Add the data boundaries TypeSpec checkpoint, scoped metadata, and ResourceManager-based generated samples.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Record the data boundaries checkpoint and reusable workflow for the remaining multi-source generation steps.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Add the deployment stacks TypeSpec-generated client at API version 2024-03-01 and preserve the legacy ActionOnUnmanage enum signatures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Regenerate deployment stacks with the legacy Java properties flattening used by the original Swagger client.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Generate the policy client at API version 2026-07-01 and preserve the legacy policy exemption client and models for compatibility.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Add an AST customization limited to PolicyClient and PolicyClientImpl so the preserved policy exemption client remains accessible.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Target the generated PolicyClient interface declaration and emit a marker Override annotation on its implementation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Apply the Java AST customization to expose the preserved PolicyExemptionsClient through PolicyClient and PolicyClientImpl.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Add policy samples for the TypeSpec-generated 2026-07-01 surface while retaining earlier project samples and excluding stale generated tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Generate the subscription client into the combined resources package while preserving the original client grouping and API version.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Use the package-specific subscription client accessor from the shared ResourceManager entry point.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Keep ResourceReference extensible for the deployment-stacks ManagedResourceReference model after deployments generation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Generate deployment clients and models into the combined resources package while preserving premium inner models, UUID types, and ResourceReference inheritance.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Use the package-specific deployment client accessor from the handwritten ResourceManager entry point.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Complete the combined resources package generation with the original client grouping, tag client name, and shared-model compatibility.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Add TypeSpec samples for providers, resource groups, provider resource types, and tag operations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Restore AssignmentScopeValidation required by policy exemption compatibility.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Refresh playback assets for TypeSpec URI casing and trailing slash changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Allow azure-core to deserialize TypeSpec paging models through reflection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Regenerate deployment stacks with separate model and delete parameter enum types, document accepted Policy service removals, and suppress reviewed migration differences.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Skip pre-generation source cleanup for azure-resourcemanager-resources so generating one TypeSpec project does not delete outputs from the package's other projects.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Generate the PolicyExemptions accessor without an explicit public modifier on the PolicyClient interface.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Use the core resources project in the Azure azure-rest-api-specs repository as the package's default generation location.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Add the Policy Exemptions client accessor and implementation only when the selected API version does not generate them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Remove the task working notes from the pull request while retaining the local file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
@github-actions github-actions Bot added the Mgmt This issue is related to a management-plane library. label Aug 12, 2026
@weidongxu-microsoft

Weidong Xu (weidongxu-microsoft) commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

Specs PR at Azure/azure-rest-api-specs#45423
We may not merge this one directly, as deploymentStack is moved out, and dataBoundaries may follow.


One major problem is that we need run an extra step to pin other lib (e.g. policy) to generate from stable (in AutoPR), if e.g. resources need to release for next stable.

And if e.g. policy need to release preview, we need then unpin it.

Seems the best we can do is to always pin them at stable. Then only unpin when any need to release a preview.


Another minor problem is a generate will delete all generated samples that not belong to it. Will handle this later, as worst case it still manageable in AutoPR.

Also need a new emitter release for the samples anyway


Another minor problem is duplicate files (from CommonTypes I guess).

### Policy (11)

- `src/main/java/com/azure/resourcemanager/resources/models/Alias.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasPath.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasPathAttributes.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasPathMetadata.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasPathTokenType.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasPattern.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasPatternType.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasType.java`
- `src/main/java/com/azure/resourcemanager/resources/models/Identity.java`
- `src/main/java/com/azure/resourcemanager/resources/models/IdentityUserAssignedIdentitiesValue.java`
- `src/main/java/com/azure/resourcemanager/resources/models/ResourceIdentityType.java`

### Deployments (14)

- `src/main/java/com/azure/resourcemanager/resources/fluent/models/ProviderInner.java`
- `src/main/java/com/azure/resourcemanager/resources/models/Alias.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasPath.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasPathAttributes.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasPathMetadata.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasPathTokenType.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasPattern.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasPatternType.java`
- `src/main/java/com/azure/resourcemanager/resources/models/AliasType.java`
- `src/main/java/com/azure/resourcemanager/resources/models/ApiProfile.java`
- `src/main/java/com/azure/resourcemanager/resources/models/ProviderAuthorizationConsentState.java`
- `src/main/java/com/azure/resourcemanager/resources/models/ProviderExtendedLocation.java`
- `src/main/java/com/azure/resourcemanager/resources/models/ProviderResourceType.java`
- `src/main/java/com/azure/resourcemanager/resources/models/ZoneMapping.java`

Likely going to have emitter support remove-model option.


Another emitter fix

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
"code": "java.method.removed",
"old": {
"matcher": "regex",
"match": "method .* com\\.azure\\.resourcemanager\\.resources\\.models\\.PolicyLogInfo\\:\\:(ancestors|complianceReasonCode|policyAssignmentDisplayName|policyDefinitionDisplayName|policyDefinitionGroupNames|policyExemptionIds|policySetDefinitionCategory|policySetDefinitionDisplayName|resourceLocation)\\(\\)"

@weidongxu-microsoft Weidong Xu (weidongxu-microsoft) Aug 12, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to handle the mistake we made a long time ago -- we release GA on a tag that includes PolicyExemptions that still is preview.

The client/model class was converted as handwritten. The MangementClient would need a customizatoin.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
33 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4fc3370c-93f9-4237-862a-f239ff79cc86
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 156aa207-7554-4621-9b96-07761ca52455
public class FeaturesTests extends ResourceManagementTest {

// Feature availability and registration state are subscription-specific.
@DoNotRecord(skipInPlayback = true)

@weidongxu-microsoft Weidong Xu (weidongxu-microsoft) Aug 13, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this time it continue failing on 1 macos CI.

But also see one case timeout at 120sec. My local run took 50sec.

Guest just disable it in playback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Mgmt This issue is related to a management-plane library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MGMT] migrate resources lib to TypeSpec

3 participants