Skip to content

enhance AzureBaseHook to return newer credential object that supports get_token method #52182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

karunpoudel
Copy link
Contributor

@karunpoudel karunpoudel commented Jun 24, 2025

Databases like Snowflake and Azure Postgres Flex support connection using Azure OAUTH token. Newer Azure Identity credential objects like ClientSecretCredential and DefaultAzureCredential support get_token method which can be used to generate OAUTH token. SnowflakeHook and PostgresHook can leverage AzureBaseHook to retrieve required token.

In this PR:

  • Expose the credential object directly using get_credential method and make sdk_client argument optional so that the credential object can be retrieved without needing sdk_client. eg. AzureBaseHook().get_credential()
  • Added new extra use_azure_identity_object in connection for backward compatibility. When set to true, get_credential method will return newer credential object of type ClientSecretCredential or DefaultAzureCredential instead of current ServicePrincipalCredentials or AzureIdentityCredentialAdapter. Current credential object doesn't support get_token method. eg. AzureBaseHook().get_credential().get_token()

I am ok with not making sdk_client argument optional if there is any concern.


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@karunpoudel karunpoudel changed the title feat: enhance AzureBaseHook to get newer credentials that support get_token method feat: enhance AzureBaseHook to get newer credential object that support get_token method Jun 24, 2025
@karunpoudel karunpoudel changed the title feat: enhance AzureBaseHook to get newer credential object that support get_token method enhance AzureBaseHook to return newer credential object that supports get_token method Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants