<PackageReference Include="Azure.Identity" Version="1.17.2" />

Azure.Identity.ManagedIdentityCredential

public class ManagedIdentityCredential : TokenCredential
Attempts authentication using a managed identity that has been assigned to the deployment environment. This authentication type works for all Azure-hosted environments that support managed identity. For end-to-end guidance, see user-assigned managed identity or system-assigned managed identity.

Protected constructor for mocking.

public ManagedIdentityCredential(string clientId = null, TokenCredentialOptions options = null)

Creates an instance of ManagedIdentityCredential capable of authenticating a resource with a user-assigned or a system-assigned managed identity.

public ManagedIdentityCredential(ResourceIdentifier resourceId, TokenCredentialOptions options = null)

Creates an instance of ManagedIdentityCredential capable of authenticating a resource with a user-assigned managed identity.

Creates an instance of ManagedIdentityCredential capable of authenticating using the specified ManagedIdentityId.

Creates an instance of ManagedIdentityCredential configured with the specified options.