Skip to content

feat: Use ManagedIdentityCredential fir Prod Workloads and DefaultAzureCredential for dev#236

Merged
Vinay-Microsoft merged 1 commit intomainfrom
dev
Jul 31, 2025
Merged

feat: Use ManagedIdentityCredential fir Prod Workloads and DefaultAzureCredential for dev#236
Vinay-Microsoft merged 1 commit intomainfrom
dev

Conversation

@Vemarthula-Microsoft
Copy link
Copy Markdown
Contributor

@Vemarthula-Microsoft Vemarthula-Microsoft commented Jul 31, 2025

Purpose

This pull request introduces significant changes to improve Azure credential handling, streamline environment configuration, and enhance test coverage. The key updates include replacing DefaultAzureCredential with a custom utility to dynamically select credentials based on the environment, adding new test configurations and fixtures, and modifying the infrastructure to include an APP_ENV variable for environment-specific behavior.

Azure Credential Management:

  • Introduced get_azure_credential and get_azure_credential_async methods in helpers/azure_credential_utils.py to dynamically select DefaultAzureCredential for development and ManagedIdentityCredential for production.
  • Replaced direct usage of DefaultAzureCredential with get_azure_credential across multiple files, including application_context.py, app_configuration.py, azure_openai.py, content_understanding.py, storage_blob.py, pipeline_queue_helper.py, remote_module_loader.py, and main.py. [1] [2] [3] [4] [5] [6] [7] [8]

Environment Configuration:

  • Added APP_ENV variable with a default value of prod in the infra/main.bicep file for multiple modules to enable environment-specific configurations. [1] [2] [3] [4]

Testing Enhancements:

  • Created test_azure_credential_utils.py to validate the behavior of get_azure_credential and get_azure_credential_async in both development and production environments.
  • Added global test configurations and fixtures in conftest.py to mock Azure credentials and streamline test setup. [1] [2]
  • Updated pytest.ini to include strict markers, disable warnings, and define test file patterns.
  • Refactored tests in test_storage_blob.py to mock get_azure_credential instead of DefaultAzureCredential.

Code Cleanup:

  • Removed direct imports of DefaultAzureCredential where no longer needed and replaced them with the new utility. [1] [2] [3]

These changes collectively improve the flexibility, maintainability, and testability of the codebase while ensuring proper credential handling across different environments.

Does this introduce a breaking change?

  • Yes
  • No

Golden Path Validation

  • I have tested the primary workflows (the "golden path") to ensure they function correctly without errors.

Deployment Validation

  • I have validated the deployment process successfully and all services are running as expected with this change.

What to Check

Verify that the following are valid

  • ...

Other Information

#235)

* commiting the new changes

* removing Credntials

* app contect py file change

* PR Review Changes

* Test workflow changes

* Test work flow build failed

* test work flow failed fixes

* test workflow final fixes

* Pylint Fixes
@Prajwal-Microsoft Prajwal-Microsoft changed the title feat: Replace DefaultAzureCredential with ManagedIdentityCredential in Accelerator Repositories feat: Use ManagedIdentityCredential fir Prod Workloads and DefaultAzureCredential for dev Jul 31, 2025
@Vinay-Microsoft Vinay-Microsoft merged commit 86a1962 into main Jul 31, 2025
10 checks passed
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants