GitHubActionsCommands.

AzurePrepareWorkloadIdentity(string, string, FilePath, CancellationToken) Method

Summary

Fetches the GitHub Actions OIDC JWT and writes it to a file for Azure.Identity WorkloadIdentityCredential. Default OIDC audience is api://AzureADTokenExchange. 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(string tenantId, string clientId, FilePath federatedTokenFile = null, CancellationToken cancellationToken = default(CancellationToken))

Examples

 var tenantId = EnvironmentVariable("AZURE_TENANT_ID");
 var clientId = EnvironmentVariable("AZURE_CLIENT_ID");
 var workload = await GitHubActions.Commands.AzurePrepareWorkloadIdentity(tenantId, clientId);

 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
tenantId string The Entra ID tenant ID.
clientId string The application (client) ID.
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.