GitHubActionsCommands.

AzureLogin(GitHubAzureLoginSettings, CancellationToken) Method

Summary

Exchanges a GitHub Actions OIDC identity token for an Azure AD access token using the specified scope, audience, and authority. Requires permissions: id-token: write in the GitHub Actions workflow. OIDC tokens and the returned access token are automatically masked in the build log.

Syntax

public Task<string> AzureLogin(GitHubAzureLoginSettings settings, CancellationToken cancellationToken = default(CancellationToken))

Examples

 var loginSettings = new GitHubAzureLoginSettings(
     tenantId: EnvironmentVariable("AZURE_TENANT_ID"),
     clientId: EnvironmentVariable("AZURE_CLIENT_ID"),
     scope: "https://management.azure.com/.default",
     audience: "api://AzureADTokenExchange",
     tokenAuthority: "https://login.microsoftonline.com");

 var accessToken = await GitHubActions.Commands.AzureLogin(loginSettings);

Parameters

Name Type Description
settings GitHubAzureLoginSettings The tenant, client, scope, OIDC audience, and optional token authority.
cancellationToken CancellationToken The cancellation token.

Return Value

Type Description
Task<string> The Azure AD access token.