chore: dev to main merge - #135
Open
Saswato-Microsoft wants to merge 2 commits into
Open
Conversation
fix: Update credential retrieval logic based on environment
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Databricks authentication token acquisition in create_databricks_items_maag.py to choose Azure Identity credentials based on the APP_ENV environment, aiming to use stricter developer-local auth and managed identity elsewhere.
Changes:
- Updated
_get_entra_token()to select an Azure Identity credential based onAPP_ENV. - Introduced
ManagedIdentityCredentialusage (withAZURE_CLIENT_ID) for non-devenvironments.
Suppressed comments (2)
infra/scripts/databricks/create_databricks_items_maag.py:319
DefaultAzureCredential(require_envvar=True)is very likely an invalid constructor argument for theazure-identityversions used in this repo (e.g.,requirements.txtpinsazure-identity==1.25.3). In that case it will raiseTypeErrorand be silently swallowed by the broadexcept, causing token acquisition to fail indevwhen Azure CLI isn't available.
credential = DefaultAzureCredential(require_envvar=True)
infra/scripts/databricks/create_databricks_items_maag.py:325
- In non-
devenvironments the PR description says to useManagedIdentityCredentialwithAZURE_CLIENT_ID, but this code will fall back to system-assigned identity whenAZURE_CLIENT_IDis unset and will also currently swallow any errors silently. Consider validatingAZURE_CLIENT_IDand surfacing the failure reason so misconfiguration is actionable.
credential = ManagedIdentityCredential(
client_id=os.environ.get("AZURE_CLIENT_ID"))
token = credential.get_token(f"{DATABRICKS_RESOURCE_ID}/.default")
if token.token:
return token.token
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| pass | ||
|
|
||
| # Method 2: azure-identity DefaultAzureCredential | ||
| # Method 2: environment-specific azure-identity credential |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This pull request updates the logic for obtaining an Entra token in
create_databricks_items_maag.pyto use different Azure identity credentials based on the environment. The main change is to useDefaultAzureCredentialwith stricter requirements in development andManagedIdentityCredentialin other environments.Credential selection improvements:
_get_entra_token()to select credentials based on theAPP_ENVenvironment variable: usesDefaultAzureCredential(require_envvar=True)indevandManagedIdentityCredentialwithAZURE_CLIENT_IDin other environments.Does this introduce a breaking change?
How to Test
What to Check
Verify that the following are valid
Other Information