Class WorkloadIdentityCredential
WorkloadIdentityCredential supports Microsoft Entra Workload ID authentication on Kubernetes and other hosts supporting workload identity. Refer to Microsoft Entra Workload ID for more information.
public class WorkloadIdentityCredential : TokenCredential
- Inheritance
-
WorkloadIdentityCredential
Constructors
WorkloadIdentityCredential()
Creates a new instance of the WorkloadIdentityCredential with the default options. When no options are specified AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_FEDERATED_TOKEN_FILE must be specified in the environment.
public WorkloadIdentityCredential()
WorkloadIdentityCredential(WorkloadIdentityCredentialOptions)
Creates a new instance of the WorkloadIdentityCredential with the specified options.
public WorkloadIdentityCredential(WorkloadIdentityCredentialOptions options)
Parameters
options
WorkloadIdentityCredentialOptionsOptions that allow to configure the management of the requests sent to Microsoft Entra ID.
Methods
GetToken(TokenRequestContext, CancellationToken)
Gets an Azure.Core.AccessToken for the specified set of scopes.
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
Parameters
requestContext
TokenRequestContextThe Azure.Core.TokenRequestContext with authentication information.
cancellationToken
CancellationTokenThe CancellationToken to use.
Returns
- AccessToken
A valid Azure.Core.AccessToken.
Remarks
Caching and management of the lifespan for the Azure.Core.AccessToken is considered the responsibility of the caller: each call should request a fresh token being requested.
GetTokenAsync(TokenRequestContext, CancellationToken)
Gets an Azure.Core.AccessToken for the specified set of scopes.
public override ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken = default)
Parameters
requestContext
TokenRequestContextThe Azure.Core.TokenRequestContext with authentication information.
cancellationToken
CancellationTokenThe CancellationToken to use.
Returns
- ValueTask<AccessToken>
A valid Azure.Core.AccessToken.
Remarks
Caching and management of the lifespan for the Azure.Core.AccessToken is considered the responsibility of the caller: each call should request a fresh token being requested.