AzureDevOpsGitHook¶
Git hook that authenticates Azure DevOps HTTPS remotes with Entra ID.
- airflow.providers.git_azure.hooks.git_azure.AZURE_DEVOPS_RESOURCE = '499b84ac-1321-427f-aa17-267ca6975798'¶
Azure DevOps resource application ID — the token audience Azure DevOps accepts for Git-over-HTTPS authentication.
- class airflow.providers.git_azure.hooks.git_azure.AzureDevOpsGitHook(git_conn_id: str = 'git_default', repo_url: str | None = None, *args: Any, **kwargs: Any)¶
Bases:
GitHookTransparent Git hook that adds Microsoft Entra ID auth for Azure DevOps.
Behaves exactly like the stock
GitHookunless the repository URL is an Azure DevOps HTTPS URL (dev.azure.comor*.visualstudio.com), in which case an Entra ID access token is minted per git command from one of two credential sources:Client secret — when the connection carries a login (client ID), a password (client secret), and a
tenant_idextra, aClientSecretCredentialis used. Note: the password is treated as an Entra client secret here, not as a git password — it is never embedded in the remote URL.Workload identity — when the connection carries no credential at all,
WorkloadIdentityCredential(falling back toDefaultAzureCredentialoutside AKS, e.g. local development).
Everything else passes through to the stock behaviour untouched: GitHub (or other) URLs, SSH-key connections (
private_key/key_fileextras), and ADO connections whose password is a PAT (i.e. notenant_idextra).Independently of the auth mode, the connection extra
tracking_refcan override the branch/tag the bundle tracks (exposed astracking_ref_override, consumed byAzureDevOpsGitDagBundle).azure-identitycaches the token internally and transparently re-mints it when it nears expiry, so every git command gets a valid token even after the ~1 hour Entra token lifetime. The token is injected per git command as anhttp.extraHeaderthroughGIT_CONFIG_*environment variables, so it is never embedded in the remote URL and never persisted to.git/config.- Parameters:
git_conn_id – Connection ID holding the repository URL as host
repo_url – Explicit Git repository URL to override the connection’s host.
- configure_hook_env()¶
Yield with self.env set to inject a fresh Entra ID token for this git command.
In Azure mode a token is minted per invocation and passed via
GIT_CONFIG_*so it never touches the remote URL or.git/config. Outside Azure mode, delegates to the stock ~airflow.providers.git.hooks.git.GitHook.configure_hook_env.
- get_access_token() str¶
Return a valid Entra ID access token for the Azure DevOps resource.
Retries on ClientAuthenticationError — see _TOKEN_MAX_ATTEMPTS.