88import asyncio
99from typing import Dict , Any , AsyncGenerator
1010
11- from azure .identity .aio import DefaultAzureCredential
12- from azure .identity import DefaultAzureCredential as DefaultAzureCredentialSync
11+
12+ from backend .helpers .azure_credential_utils import get_azure_credential
13+ from backend .helpers .azure_credential_utils import get_azure_credential_async
1314from quart import (Blueprint , Quart , jsonify , make_response , render_template ,
1415 request , send_from_directory )
1516
@@ -169,7 +170,7 @@ async def init_ai_foundry_client():
169170
170171 ai_project_client = AIProjectClient (
171172 endpoint = app_settings .azure_ai .agent_endpoint ,
172- credential = DefaultAzureCredential ()
173+ credential = get_azure_credential ()
173174 )
174175 track_event_if_configured ("AIFoundryAgentEndpointUsed" , {
175176 "endpoint" : app_settings .azure_ai .agent_endpoint
@@ -193,7 +194,7 @@ def init_cosmosdb_client():
193194 )
194195
195196 if not app_settings .chat_history .account_key :
196- credential = DefaultAzureCredential ()
197+ credential = get_azure_credential ()
197198 else :
198199 credential = app_settings .chat_history .account_key
199200
@@ -1163,7 +1164,7 @@ async def fetch_azure_search_content():
11631164 return jsonify ({"error" : "URL and title are required" }), 400
11641165
11651166 # Get Azure AD token
1166- credential = DefaultAzureCredentialSync ()
1167+ credential = await get_azure_credential_async ()
11671168 token = credential .get_token ("https://search.azure.com/.default" )
11681169 access_token = token .token
11691170
0 commit comments