AcquireTokenOptions.ManagedIdentity Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
When ManagedIdentity is set, the application uses a managed identity instead of client credentials to acquire an app token. To use a system-assigned identity, simply leave UserAssignedClientId null. To use a user-assigned identity, set UserAssignedClientId to the ClientID of the user-assigned identity you want to use. Using either form of managed identity requires the application to be deployed on Azure and the managed identity to be configured. For more details, check the managed identities for Azure documentation.
public Microsoft.Identity.Abstractions.ManagedIdentityOptions? ManagedIdentity { get; set; }
member this.ManagedIdentity : Microsoft.Identity.Abstractions.ManagedIdentityOptions with get, set
Public Property ManagedIdentity As ManagedIdentityOptions
Property Value
Examples
The Json fragment below describes how to use a system-assigned Managed Identity for authentication in a confidential client application :
The code below describes the same, programmatically in C#.
The Json fragment below describes how to use a user-assigned Managed Identity for authentication in a confidential client application :
{
"AquireTokenOptions": {
"ManagedIdentity": {
"UserAssignedClientId": "[ClientIdForTheManagedIdentityResource]"
}
}
}
The code below describes the same, programmatically in C#.
ManagedIdentityOptions managedIdentityOptions = new ManagedIdentityOptions
{
UserAssignedClientId = "[ClientIdForTheManagedIdentityResource]"
};
AcquireTokenOptions acquireTokenOptions = new AcquireTokenOptions
{
ManagedIdentity = managedIdentityOptions
};
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈