chore: Dev to Main - #686
Open
PadhiAjit-Microsoft wants to merge 5 commits into
Open
Conversation
Coverage Report •
|
||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates Azure credential selection for the ContentProcessor utilities, aiming to differentiate production vs. development behavior using APP_ENV, and aligns async token-provider creation and tests with the updated (non-async) credential factory.
Changes:
- Updated async bearer token provider helpers to call
get_async_azure_credential()synchronously (noawait). - Modified
get_async_azure_credential()to prefer managed identity whenAPP_ENV=prod, and fall back toAsyncDefaultAzureCredentialotherwise, with updated logging. - Updated unit tests to set
APP_ENV=devand to patch the (now non-async) credential factory appropriately.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/ContentProcessor/src/libs/utils/azure_credential_utils.py | Adjusts async credential selection logic based on APP_ENV and updates fallback/logging behavior. |
| src/ContentProcessor/src/libs/utils/credential_util.py | Removes await when retrieving the async credential factory for token-provider creation. |
| src/tests/ContentProcessor/utils/test_azure_credential_utils.py | Updates environment setup to set APP_ENV=dev to match new fallback behavior. |
| src/tests/ContentProcessor/utils/test_azure_credential_utils_extended.py | Updates environment setup and mocking to match the non-async credential factory behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+194
to
+206
| app_env = os.getenv("APP_ENV", "prod").lower() | ||
| if app_env == "prod": | ||
| client_id = os.getenv("AZURE_CLIENT_ID") | ||
| if client_id: | ||
| logging.info( | ||
| "[AUTH] APP_ENV=prod -> using async user-assigned managed identity: %s", | ||
| client_id, | ||
| ) | ||
| return AsyncManagedIdentityCredential(client_id=client_id) | ||
| logging.info( | ||
| "[AUTH] APP_ENV=prod -> using async system-assigned managed identity" | ||
| ) | ||
| return AsyncManagedIdentityCredential() |
Comment on lines
109
to
111
| for key in ["WEBSITE_SITE_NAME", "AZURE_CLIENT_ID", "MSI_ENDPOINT", | ||
| "IDENTITY_ENDPOINT", "KUBERNETES_SERVICE_HOST"]: | ||
| monkeypatch.delenv(key, raising=False) |
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
APP_ENVenvironment variable. The main change is to ensure that in production, the code prefers user-assigned or system-assigned managed identities, and only falls back toAsyncDefaultAzureCredentialin development. Additionally, the way credentials are retrieved in async functions has been adjusted, and tests have been updated to reflect the new logic.Azure credential selection logic:
src/ContentProcessor/src/libs/utils/azure_credential_utils.py: Changedget_async_azure_credential()to checkAPP_ENV; in production, it now uses user-assigned or system-assigned managed identity, and only falls back toAsyncDefaultAzureCredentialin other environments. Improved logging to clarify credential selection.Async credential retrieval:
src/ContentProcessor/src/libs/utils/azure_credential_utils.pyandsrc/ContentProcessor/src/libs/utils/credential_util.py: Updatedget_async_bearer_token_provider()to callget_async_azure_credential()synchronously instead of awaiting it, reflecting that the credential function is no longer async. [1] [2]Test updates:
src/tests/ContentProcessor/utils/test_azure_credential_utils.py: Updated tests to setAPP_ENVto "dev" to match the new credential selection logic.src/tests/ContentProcessor/utils/test_azure_credential_utils_extended.py: SetAPP_ENVto "dev" in relevant tests and updated mocks to match the new (non-async) credential retrieval. [1] [2]Does this introduce a breaking change?
Golden Path Validation
Deployment Validation
What to Check
Verify that the following are valid
Other Information