GitHubActionsCommands.

AzurePrepareWorkloadIdentity(GitHubAzureLoginSettings, FilePath, CancellationToken) Method

Summary

Fetches the GitHub Actions OIDC JWT and writes it to a file for Azure.Identity WorkloadIdentityCredential. Requires permissions: id-token: write in the GitHub Actions workflow. The OIDC JWT is automatically masked in the build log.

Syntax

public Task<GitHubAzureWorkloadIdentityInfo> AzurePrepareWorkloadIdentity(GitHubAzureLoginSettings settings, FilePath federatedTokenFile = null, CancellationToken cancellationToken = default(CancellationToken))

Examples

 var loginSettings = new GitHubAzureLoginSettings(
     tenantId: EnvironmentVariable("AZURE_TENANT_ID"),
     clientId: EnvironmentVariable("AZURE_CLIENT_ID"));

 var workload = await GitHubActions.Commands.AzurePrepareWorkloadIdentity(loginSettings);

 InstallTool("dotnet:?package=ARI&version=2026.9.9.1110");
 Command(
     new CommandSettings
     {
         ToolName = "ari",
         ToolExecutableNames = ["ari", "ari.exe"],
         EnvironmentVariables =
         {
             { "AZURE_TENANT_ID", workload.TenantId },
             { "AZURE_CLIENT_ID", workload.ClientId },
             { "AZURE_FEDERATED_TOKEN_FILE", workload.FederatedTokenFile.FullPath }
         }
     },
     new ProcessArgumentBuilder()
         .Append("inventory")
         .AppendQuotedSecret(workload.TenantId)
         .AppendQuoted("./artifacts/inventory")
         .Append("--skip-tenant-overview")
         .Append("--include-site-application-settings"));

Parameters

Name Type Description
settings GitHubAzureLoginSettings The tenant, client, and OIDC audience; scope and token authority are ignored.
federatedTokenFile FilePath Optional destination path; default is a unique file under the local temp directory.
cancellationToken CancellationToken The cancellation token.

Return Value

Type Description
Task<GitHubAzureWorkloadIdentityInfo> Tenant ID, client ID, and federated token file path.