-
Notifications
You must be signed in to change notification settings - Fork 366
Managed Identity Support in MSAL
Neha Bhargava edited this page Jan 27, 2023
·
22 revisions
This is an experimental feature for 1st party use only.
A common challenge for developers is the management of secrets, credentials, certificates, and keys used to secure communication between services. Managed identities eliminate the need for developers to manage these credentials.
IConfidentialClientApplication cca = ConfidentialClientApplicationBuilder.Create(clientId)
.WithExperimentalFeatures()
.Build();
AuthenticationResult result = await cca.AcquireTokenForClient(scopes)
.WithManagedIdentity(userAssignedClientOrResourceId) // userAssignedClientIdOrResourceId is optional. To be provided only in case of user assigned managed identity.
.ExecuteAsync()
.ConfigureAwait(false);
- The scopes array should contain a single scope as managed identity acquires token for a resource.
- The parameter userAssignedClientIdOrResourceId can either contain the client id of the user assigned managed identity or the resource id in case the client id is not yet available.
- For system assigned managed identity the parameter userAssignedClientIdOrResourceId need not be passed.
MSAL supports the following sources for managed identity
Supported:
- App services
- IMDS (VMs)
- Azure Arc
In Progress:
- Cloud Shell
- Service Fabric
MsalServiceException Error Code: managed_identity_failed_response Error Message: An unexpected error occurred while fetching the AAD token
This exception might mean that the scope added is either not supported or is in wrong format. An example of expected scope is https://management.azure.com/.default
- Home
- Why use MSAL.NET
- Is MSAL.NET right for me
- Scenarios
- Register your app with AAD
- Client applications
- Acquiring tokens
- MSAL samples
- Known Issues
- Acquiring a token for the app
- Acquiring a token on behalf of a user in Web APIs
- Acquiring a token by authorization code in Web Apps
- AcquireTokenInteractive
- WAM - the Windows broker
- .NET Core
- Maui Docs
- Custom Browser
- Applying an AAD B2C policy
- Integrated Windows Authentication for domain or AAD joined machines
- Username / Password
- Device Code Flow for devices without a Web browser
- ADFS support
- High Availability
- Regional
- Token cache serialization
- Logging
- Exceptions in MSAL
- Provide your own Httpclient and proxy
- Extensibility Points
- Clearing the cache
- Client Credentials Multi-Tenant guidance
- Performance perspectives
- Differences between ADAL.NET and MSAL.NET Apps
- PowerShell support
- Testing apps that use MSAL
- Experimental Features
- Proof of Possession (PoP) tokens
- Using in Azure functions
- Extract info from WWW-Authenticate headers
- SPA Authorization Code