[Identity] Deprecate legacy ManagedIdentityCredential constructors#53825
[Identity] Deprecate legacy ManagedIdentityCredential constructors#53825JonathanCrd merged 7 commits intomainfrom
Conversation
…ors and update usages Co-authored-by: JonathanCrd <[email protected]>
Co-authored-by: JonathanCrd <[email protected]>
|
@copilot Update these 2 tests too: |
…onstructor Co-authored-by: scottaddie <[email protected]>
|
@copilot Run ./eng/scripts/Export-API.ps1 <service_directory_name> for each changed project. The <service_directory_name> placeholder refers to the name of the directory under the sdk directory, such as "identity" or "extensions". |
Co-authored-by: scottaddie <[email protected]>
Ran |
There was a problem hiding this comment.
Pull Request Overview
This PR deprecates two legacy ManagedIdentityCredential constructors that lack clarity around system-assigned vs. user-assigned managed identity intent, replacing them with newer constructors that use explicit ManagedIdentityId parameters for better code clarity.
- Adds
[Obsolete]attributes to legacy constructors inManagedIdentityCredential - Updates API listing files to reflect deprecation
- Migrates
Microsoft.Extensions.Azurecode to use the new constructor pattern
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/identity/Azure.Identity/src/Credentials/ManagedIdentityCredential.cs | Added Obsolete attributes to two legacy constructors with guidance messages |
| sdk/identity/Azure.Identity/api/Azure.Identity.netstandard2.0.cs | Updated API listing to reflect Obsolete attributes for netstandard2.0 target |
| sdk/identity/Azure.Identity/api/Azure.Identity.net8.0.cs | Updated API listing to reflect Obsolete attributes for net8.0 target |
| sdk/identity/Azure.Identity/CHANGELOG.md | Documented the deprecation in the changelog |
| sdk/extensions/Microsoft.Extensions.Azure/src/Internal/ClientFactory.cs | Migrated from deprecated constructors to new ManagedIdentityId factory methods while preserving existing behavior |
| sdk/extensions/Microsoft.Extensions.Azure/tests/AzureClientFactoryTests.cs | Updated tests to use explicit ManagedIdentityId.SystemAssigned instead of parameterless constructor |
|
@copilot update these references too: |
Co-authored-by: JonathanCrd <[email protected]>
Updated the integration test to use the new constructor patterns:
Changes in commit 18a3672. |
Co-authored-by: scottaddie <[email protected]>
jsquire
left a comment
There was a problem hiding this comment.
Extensions package looks good.
|
/check-enforcer evaluate |
Description
Deprecates two legacy
ManagedIdentityCredentialconstructors that lack clarity around system-assigned vs. user-assigned managed identity intent. These constructors are already hidden from IntelliSense via[EditorBrowsable(EditorBrowsableState.Never)].Changes
Azure.Identity
[Obsolete]toManagedIdentityCredential(string clientId, TokenCredentialOptions options)[Obsolete]toManagedIdentityCredential(ResourceIdentifier resourceId, TokenCredentialOptions options)ManagedIdentityTests.csto use new constructor patternMicrosoft.Extensions.Azure
ClientFactory.CreateCredential()to useManagedIdentityIdfactory methods instead of deprecated constructorsAzureClientFactoryTests.cstests to use new constructor pattern:UsesProvidedCredentialIfOverGlobaltestUsesGlobalCredentialtestMigration Path
This checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
Testing Guidelines
SDK Generation Guidelines
If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.
The generate.cmd file for the SDK has been updated with the version of AutoRest, as well as the commitid of your swagger spec or link to the swagger spec, used to generate the code.
The
*.csprojandAssemblyInfo.csfiles have been updated with the new version of the SDK.Fixes Deprecate legacy ManagedIdentityCredential ctors #53800
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.