feat: replacing DefaultAzureCredential with ManagedIdentityCredential - #350
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces environment-based Azure credential management by replacing direct usage of DefaultAzureCredential with a utility that switches between DefaultAzureCredential for development environments and ManagedIdentityCredential for production environments.
- Added
azure_credential_utils.pyhelper module with synchronous and asynchronous credential management functions - Updated multiple backend files to use the new credential utility instead of directly instantiating
DefaultAzureCredential - Added
APP_ENVenvironment variable support across configuration files and infrastructure
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/backend/helpers/azure_credential_utils.py | New utility module providing environment-based credential selection |
| src/backend/app_config.py | Updated to use credential utility and removed deprecated get_azure_credentials method |
| src/backend/config_kernel.py | Updated to use new credential utility |
| src/backend/context/cosmos_memory_kernel.py | Replaced direct DefaultAzureCredential usage with utility function |
| src/backend/utils_kernel.py | Updated credential instantiation to use utility function |
| src/backend/tests/helpers/test_azure_credential_utils.py | Added comprehensive tests for the new credential utility |
| src/backend/tests/test_config.py | Removed outdated credential-related tests |
| src/backend/.env.sample | Added APP_ENV environment variable |
| src/frontend/.env.sample | Added APP_ENV environment variable |
| infra/main.bicep | Added APP_ENV configuration for container app and website |
Prajwal-Microsoft
approved these changes
Jul 29, 2025
blessing-msft
pushed a commit
that referenced
this pull request
Aug 1, 2025
feat: replacing DefaultAzureCredential with ManagedIdentityCredential
|
🎉 This PR is included in version 2.2.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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 introduces changes to improve Azure credential handling by introducing a utility for managing credentials based on the environment (
devorprod). It also updates various files to use this utility, adds environment variable support forAPP_ENV, and includes new tests for the credential utility.Azure credential management improvements:
helpers/azure_credential_utils.pyto provide synchronous and asynchronous credential utilities that switch betweenDefaultAzureCredentialfordevenvironments andManagedIdentityCredentialforprodenvironments.src/backend/app_config.py,src/backend/config_kernel.py,src/backend/context/cosmos_memory_kernel.py, andsrc/backend/utils_kernel.pyto replace direct usage ofDefaultAzureCredentialwith the new utilityget_azure_credential. [1] [2] [3] [4] [5] [6]Environment variable updates:
APP_ENVenvironment variable in.env.samplefiles for both backend and frontend to specify the application environment (devorprod). [1] [2]infra/main.bicepto includeAPP_ENVin container app and website configurations. [1] [2]Testing enhancements:
src/backend/tests/helpers/test_azure_credential_utils.pyto test both synchronous and asynchronous credential utilities fordevandprodenvironments.DefaultAzureCredentialfromsrc/backend/tests/test_config.py.Does this introduce a breaking change?
How to Test
What to Check
Verify that the following are valid
Other Information