Skip to content

Commit d1b7a16

Browse files
refactor: move Azure Management scope to config and organize imports
1 parent f355a0d commit d1b7a16

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/backend/common/config/app_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def __init__(self):
3939
"AZURE_COGNITIVE_SERVICES", "https://cognitiveservices.azure.com/.default"
4040
)
4141

42+
self.AZURE_MANAGEMENT_SCOPE = self._get_optional(
43+
"AZURE_MANAGEMENT_SCOPE", "https://management.azure.com/.default"
44+
)
45+
4246
# Azure OpenAI settings
4347
self.AZURE_OPENAI_DEPLOYMENT_NAME = self._get_required(
4448
"AZURE_OPENAI_DEPLOYMENT_NAME", "gpt-4o"

src/backend/v3/common/services/foundry_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Any, Dict
22
import logging
3+
import re
34
from azure.ai.projects.aio import AIProjectClient
45
from git import List
56
import aiohttp
@@ -54,12 +55,11 @@ async def list_model_deployments(self) -> List[Dict[str, Any]]:
5455
try:
5556
# Get Azure Management API token (not Cognitive Services token)
5657
credential = config.get_azure_credentials()
57-
token = credential.get_token("https://management.azure.com/.default")
58+
token = credential.get_token(config.AZURE_MANAGEMENT_SCOPE)
5859

5960
# Extract Azure OpenAI resource name from endpoint URL
6061
openai_endpoint = config.AZURE_OPENAI_ENDPOINT
6162
# Extract resource name from URL like "https://aisa-macae-d3x6aoi7uldi.openai.azure.com/"
62-
import re
6363
match = re.search(r'https://([^.]+)\.openai\.azure\.com', openai_endpoint)
6464
if not match:
6565
self.logger.error(f"Could not extract resource name from endpoint: {openai_endpoint}")

0 commit comments

Comments
 (0)