Interface IAzureKeyVault
- Namespace
- Invex.Atom.Module.AzureKeyVault
- Assembly
- Invex.Atom.Module.AzureKeyVault.dll
Provides integration with Azure Key Vault for managing secrets and configuration.
[ConfigureHostBuilder]
public interface IAzureKeyVault : IBuildAccessor
- Inherited Members
Remarks
This interface defines the parameters required to connect to an Azure Key Vault and configures the necessary services for retrieving secrets.
The vault is accessed with a Microsoft Entra token credential, selected in this order:
- AzureKeyVaultTenantId, AzureKeyVaultClientId and AzureKeyVaultClientSecret: a client secret credential.
-
AzureKeyVaultTenantId and AzureKeyVaultClientId in a GitHub Actions job
with the
id-token: writepermission: the job's OIDC token, exchanged through a federated credential on the app registration. -
AzureKeyVaultTenantId, AzureKeyVaultClientId and
AzureKeyVaultServiceConnectionId in Azure Pipelines with
SYSTEM_ACCESSTOKENmapped into the step: a workload identity federation service connection. -
Otherwise
DefaultAzureCredential(environment variables, workload identity, managed identity, Azure CLI, Azure Developer CLI, ...), followed by an interactive browser login when not running headless.
Properties
AzureKeyVaultAddress
Gets the address (URI) of the Azure Key Vault, for example https://my-vault.vault.azure.net/.
[ParamDefinition("azure-key-vault-address", "Address (URI) of the Azure Key Vault", ParamSource.All, null)]
string? AzureKeyVaultAddress { get; }
Property Value
- string
Remarks
This parameter is crucial for identifying which Azure Key Vault instance to connect to.
It can be provided via command-line arguments, environment variables, or appsettings.json.
AzureKeyVaultAuthPort
Gets the port number for the local redirect of the interactive browser login.
[ParamDefinition("azure-key-vault-auth-port", "Port for local auth redirect (default 3421). Set to 0 to use a random port.", ParamSource.All, null)]
int AzureKeyVaultAuthPort { get; }
Property Value
- int
Remarks
Only used when no other credential is available and the build is not running headless. The default port is 3421. Setting this to 0 will select a random available port.
AzureKeyVaultClientId
Gets the client (application) ID of the app registration or user-assigned managed identity that has access to the Azure Key Vault.
[ParamDefinition("azure-key-vault-client-id", "Client ID of the app registration or managed identity that has access to the Azure Key Vault", ParamSource.All, null)]
string? AzureKeyVaultClientId { get; }
Property Value
- string
Remarks
Required for client secret and federated (OIDC) authentication. With DefaultAzureCredential it is
used as the workload identity and managed identity client ID. The identity needs permission to get secrets
from the vault (for example the Key Vault Secrets User role).
AzureKeyVaultClientSecret
Gets the client secret of the app registration that has access to the Azure Key Vault.
[SecretDefinition("azure-key-vault-client-secret", "Client secret of the app registration that has access to the Azure Key Vault", ParamSource.All, null)]
string? AzureKeyVaultClientSecret { get; }
Property Value
- string
Remarks
Optional. When set together with AzureKeyVaultTenantId and AzureKeyVaultClientId, client secret authentication is used. Prefer federated credentials (OIDC) in CI where possible. This value is never looked up in the vault itself.
AzureKeyVaultServiceConnectionId
Gets the ID of the Azure DevOps service connection (workload identity federation) used to authenticate in Azure Pipelines.
[ParamDefinition("azure-key-vault-service-connection-id", "Azure DevOps service connection ID for workload identity federation with Azure Key Vault", ParamSource.All, null)]
string? AzureKeyVaultServiceConnectionId { get; }
Property Value
- string
Remarks
Only used in Azure Pipelines, where SYSTEM_ACCESSTOKEN must also be mapped into the target step's
environment.
AzureKeyVaultTenantId
Gets the Microsoft Entra tenant ID used to authenticate with the Azure Key Vault.
[ParamDefinition("azure-key-vault-tenant-id", "Microsoft Entra tenant ID for Azure Key Vault authentication", ParamSource.All, null)]
string? AzureKeyVaultTenantId { get; }
Property Value
- string
Remarks
Required for client secret and federated (OIDC) authentication. When set, it also restricts
DefaultAzureCredential and interactive login to this tenant.
AzureKeyVaultTimeout
Gets the timeout, in seconds, for retrieving a single secret from Azure Key Vault, including any authentication that the request triggers.
[ParamDefinition("azure-key-vault-timeout", "Timeout in seconds for retrieving a secret from Azure Key Vault (default 120). Set to 0 to disable.", ParamSource.All, null)]
int AzureKeyVaultTimeout { get; }
Property Value
- int
Remarks
The default is 120 seconds, which leaves time to complete an interactive login. Set to 0 to disable the timeout and rely only on the build's cancellation token.
AzureKeyVaultValueInjections
Configures how Azure Key Vault parameter values are injected into generated workflows.
AzureKeyVaultValueInjections AzureKeyVaultValueInjections { get; }
Property Value
Remarks
This property allows customization of the source for each Azure Key Vault related parameter. By default, the address, tenant ID and client ID are read from workflow variables, the client secret from the platform's secret store, and the service connection ID is not injected.
Methods
ConfigureHostBuilderFromIAzureKeyVault(IHostApplicationBuilder)
Configures the host builder to add Azure Key Vault services.
protected static void ConfigureHostBuilderFromIAzureKeyVault(IHostApplicationBuilder builder)
Parameters
builderIHostApplicationBuilderThe host application builder.
Remarks
This method registers the Azure Key Vault ISecretsProvider and an IBuildOptionProvider that injects the vault connection parameters into generated workflows. Both implementations are internal to this module.