fix: Refactor to reuse Azure credentials and implement async processing#955
Merged
Conversation
…t Understanding, OpenAI, and Agent operations. Wrapped the entire processing pipeline in an async main() entry point.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors the two Content Understanding indexing scripts to reuse a single Azure CLI credential per script and to standardize execution around a single async main() entrypoint, reducing repeated auth setup and avoiding nested asyncio.run() calls.
Changes:
- Converted both scripts to
async def main()withasyncio.run(main()), and refactored internal flows to useawaitconsistently. - Reused a shared
AzureCliCredentialacross DataLake/Search/CU/OpenAI token flows and added explicit credential cleanup. - Updated agent creation / topic-mining flows to run within the async orchestration and reuse shared async credential instances.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| infra/scripts/index_scripts/03_cu_process_data_text.py | Refactors script orchestration to async, reuses a shared Azure CLI credential, and adjusts agent/topic-mining flow accordingly. |
| infra/scripts/index_scripts/04_cu_process_custom_data.py | Same async + shared-credential refactor for the “custom data” processing path, including search index recreation and agent lifecycle handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Avijit-Microsoft
approved these changes
Jun 8, 2026
Contributor
|
🎉 This PR is included in version 3.23.3 🎉 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 refactors the main entrypoints of
03_cu_process_data_text.pyand04_cu_process_custom_data.pyto useasyncioand shared credentials more consistently, improving resource management and code clarity. The changes ensure that asynchronous operations are properly awaited, credentials are reused and closed correctly, and redundant instantiations are eliminated.Refactoring for async/await and credential management:
03_cu_process_data_text.pyand04_cu_process_custom_data.py) in anasync def main()function and updated the entrypoint to useasyncio.run(main()), ensuring all async operations are properly awaited. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]AzureCliCredentialandAsyncAzureCliCredentialwith a single shared instance per script, which is reused for all Azure service clients (DataLake, Search, Content Understanding, etc.). [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]Improvements to asynchronous agent management:
These changes make the scripts more robust, maintainable, and efficient in their use of asynchronous programming and Azure credentials.
Does this introduce a breaking change?
Golden Path Validation
Deployment Validation