Skip to content

Commit 61e12a7

Browse files
Merge pull request #526 from microsoft/psl-asyncsfi
refactor: Changed Async and Sync Azure credential retrieval
2 parents 1bb4cc0 + 19b12e5 commit 61e12a7

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ async def init_ai_foundry_client():
170170

171171
ai_project_client = AIProjectClient(
172172
endpoint=app_settings.azure_ai.agent_endpoint,
173-
credential=get_azure_credential()
173+
credential=await get_azure_credential_async()
174174
)
175175
track_event_if_configured("AIFoundryAgentEndpointUsed", {
176176
"endpoint": app_settings.azure_ai.agent_endpoint
@@ -1164,7 +1164,7 @@ async def fetch_azure_search_content():
11641164
return jsonify({"error": "URL and title are required"}), 400
11651165

11661166
# Get Azure AD token
1167-
credential = await get_azure_credential_async()
1167+
credential = get_azure_credential()
11681168
token = credential.get_token("https://search.azure.com/.default")
11691169
access_token = token.token
11701170

src/backend/api/agent/browse_agent_factory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from azure.ai.projects.aio import AIProjectClient
22
from azure.ai.agents.models import AzureAISearchTool, AzureAISearchQueryType
3-
from backend.helpers.azure_credential_utils import get_azure_credential
3+
from backend.helpers.azure_credential_utils import get_azure_credential_async
44
from backend.settings import app_settings
55
from event_utils import track_event_if_configured
66

@@ -20,7 +20,7 @@ async def create_or_get_agent(cls):
2020
"""
2121
project_client = AIProjectClient(
2222
endpoint=app_settings.azure_ai.agent_endpoint,
23-
credential=get_azure_credential(),
23+
credential=await get_azure_credential_async(),
2424
api_version=app_settings.azure_ai.agent_api_version
2525
)
2626

src/backend/api/agent/section_agent_factory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from azure.ai.projects.aio import AIProjectClient
22
from azure.ai.agents.models import AzureAISearchTool, AzureAISearchQueryType
3-
from backend.helpers.azure_credential_utils import get_azure_credential
3+
from backend.helpers.azure_credential_utils import get_azure_credential_async
44
from backend.settings import app_settings
55
from event_utils import track_event_if_configured
66

@@ -19,7 +19,7 @@ async def create_or_get_agent(cls):
1919
"""
2020
project_client = AIProjectClient(
2121
endpoint=app_settings.azure_ai.agent_endpoint,
22-
credential=get_azure_credential(),
22+
credential=await get_azure_credential_async(),
2323
api_version=app_settings.azure_ai.agent_api_version
2424
)
2525

src/backend/api/agent/template_agent_factory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from azure.ai.projects.aio import AIProjectClient
22
from azure.ai.agents.models import AzureAISearchTool, AzureAISearchQueryType
3-
from backend.helpers.azure_credential_utils import get_azure_credential
3+
from backend.helpers.azure_credential_utils import get_azure_credential_async
44
from backend.settings import app_settings
55
from event_utils import track_event_if_configured
66

@@ -20,7 +20,7 @@ async def create_or_get_agent(cls):
2020
"""
2121
project_client = AIProjectClient(
2222
endpoint=app_settings.azure_ai.agent_endpoint,
23-
credential=get_azure_credential(),
23+
credential=await get_azure_credential_async(),
2424
api_version=app_settings.azure_ai.agent_api_version
2525
)
2626

0 commit comments

Comments
 (0)