Skip to content

Conversation

@Prasanjeet-Microsoft
Copy link
Contributor

Purpose

This pull request introduces a significant refactor to replace the usage of DefaultAzureCredential with a custom utility function get_azure_credential across the codebase. It also adds a new environment variable APP_ENV to differentiate between development and production environments. The most important changes are grouped below by theme.

Credential Management Refactor:

  • Introduced get_azure_credential and get_azure_credential_async in azure_credential_utils.py to dynamically select between DefaultAzureCredential and ManagedIdentityCredential based on the APP_ENV environment variable ([code/backend/batch/utilities/helpers/azure_credential_utils.pyR1-R48](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-7da5073cced326c7dced13c0768484d67ae146b74dd907b44ebc20eb78bb9a7bR1-R48)).
  • Replaced DefaultAzureCredential with get_azure_credential in multiple files, including database_factory.py, postgresdbservice.py, azure_blob_storage_client.py, azure_computer_vision_client.py, azure_form_recognizer_helper.py, azure_postgres_helper.py, azure_search_helper.py, env_helper.py, llm_helper.py, azure_search_datasource.py, azure_search_index.py, and azure_search_indexer.py ([[1]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-a92ad8584f19aec266f80fe1d5decb9f8603008378f3c9c9cca31dc1401b3e29L5-R5), [[2]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-a92ad8584f19aec266f80fe1d5decb9f8603008378f3c9c9cca31dc1401b3e29L28-R28), [[3]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-e7dfe35613384cb3374f9b90a8ec2f7effb9e3f09f6c693636cce07fa4904987L4-R4), [[4]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-e7dfe35613384cb3374f9b90a8ec2f7effb9e3f09f6c693636cce07fa4904987L24-R24), [[5]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-0501618008f86eacf193f09a72a1f5ec7bf348b4b19e5c937657d62e039a75f3L15-R15), [[6]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-0501618008f86eacf193f09a72a1f5ec7bf348b4b19e5c937657d62e039a75f3L28-R28), [[7]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-0501618008f86eacf193f09a72a1f5ec7bf348b4b19e5c937657d62e039a75f3L59-R59), [[8]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-b228a7a21f60cbc2f450086e1f8b430ab70df4579c1dae4c91dcc9d60477804fL3-R4), [[9]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-b228a7a21f60cbc2f450086e1f8b430ab70df4579c1dae4c91dcc9d60477804fL59-R60), [[10]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-c2f405722abb3fba86580c300caa1b9e14ea410594b11765a470cdbb703f5011L4-R4), [[11]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-c2f405722abb3fba86580c300caa1b9e14ea410594b11765a470cdbb703f5011L22-R22), [[12]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-50e3408b3f05e1cdccee7e3d8138209baebda958477121fe6a7e7c8289b89060L4-R4), [[13]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-50e3408b3f05e1cdccee7e3d8138209baebda958477121fe6a7e7c8289b89060L27-R27), [[14]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-8acbb6b44f9a1c4104fd339b585d57d8d628f8ceace3ccc6db9266b23c3106a7L5-R5), [[15]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-8acbb6b44f9a1c4104fd339b585d57d8d628f8ceace3ccc6db9266b23c3106a7L52-R55), [[16]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-8acbb6b44f9a1c4104fd339b585d57d8d628f8ceace3ccc6db9266b23c3106a7L64-R64), [[17]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-8acbb6b44f9a1c4104fd339b585d57d8d628f8ceace3ccc6db9266b23c3106a7L288-R288), [[18]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-7503275e90a545dba3519622ff9d0866a73e814ddbfbb61156137721bf2a6552L6-R7), [[19]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-7503275e90a545dba3519622ff9d0866a73e814ddbfbb61156137721bf2a6552L219-R220), [[20]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-7503275e90a545dba3519622ff9d0866a73e814ddbfbb61156137721bf2a6552L419-R420), [[21]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-7503275e90a545dba3519622ff9d0866a73e814ddbfbb61156137721bf2a6552L431-R432), [[22]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-43896759bad4bc2119807845cbb205a535d9caec19b671e07dcb6cfe73ec421aL11-R11), [[23]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-43896759bad4bc2119807845cbb205a535d9caec19b671e07dcb6cfe73ec421aL169-R169), [[24]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-191306cd0087ff3adec6be22022a25f09ad71cd8596aebb0050de612ec0b091eL10-R10), [[25]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-191306cd0087ff3adec6be22022a25f09ad71cd8596aebb0050de612ec0b091eL22-R22), [[26]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-9110c8709dac7271099ab02556bef8c9a110c6413badfff59eb0119c570d91a7L24-R24), [[27]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-9110c8709dac7271099ab02556bef8c9a110c6413badfff59eb0119c570d91a7L42-R42), [[28]](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-5a2966c08715e2d467100ebf3b4a58b5fc3a34159aee19f22c0341d50a929dfcL5-R5)).

Environment Configuration:

  • Added a new APP_ENV variable to .env.sample to specify the application environment (e.g., dev or prod) ([.env.sampleR66-R67](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-088d9f35d23a4347d221d71dd49b02b95001dff4abe637a40fe0bc04d502049cR66-R67)).

Bug Fix:

  • Fixed a typo in the environment variable name from SEMENTIC_KERNEL_SYSTEM_PROMPT to SEMANTIC_KERNEL_SYSTEM_PROMPT in env_helper.py ([code/backend/batch/utilities/helpers/env_helper.pyL364-R366](https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator/pull/1872/files#diff-7503275e90a545dba3519622ff9d0866a73e814ddbfbb61156137721bf2a6552L364-R366)).

These changes improve the flexibility of credential management by supporting both development and production environments while maintaining security best practices.

Does this introduce a breaking change?

  • Yes
  • No

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install

What to Check

Verify that the following are valid:

  • All usages of DefaultAzureCredential replaced
  • Authentication logic tested locally or in a dev environment
  • Regression tested (i.e., existing functionality relying on authentication continues to work)
  • Confirmed no hardcoded secrets or fallback dev credentials remain

@Prajwal-Microsoft Prajwal-Microsoft merged commit 452acb8 into Azure-Samples:sfi-cred-change Aug 1, 2025
1 check passed
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.

2 participants