Skip to content

Commit

Permalink
Further bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BenConstable9 committed Sep 10, 2024
1 parent a9386a9 commit 0634e24
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ai_search_with_adi/adi_function_app/adi_2_ai_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async def understand_image_with_gptv(image_base64, caption, tries_left=3):
elif get_identity_type() != IdentityType.USER_ASSIGNED:
token_provider = get_bearer_token_provider(
DefaultAzureCredential(
managed_identity_client_id=os.environ["FunctionApp__ClientId"]
managed_identity_client_id=os.environ.get("FunctionApp__ClientId")
),
"https://cognitiveservices.azure.com/.default",
)
Expand Down
6 changes: 3 additions & 3 deletions ai_search_with_adi/adi_function_app/key_phrase_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ async def extract_key_phrases_from_text(
credential = DefaultAzureCredential()
elif get_identity_type() == IdentityType.USER_ASSIGNED:
credential = DefaultAzureCredential(
managed_identity_client_id=os.environ["FunctionApp__ClientId"]
managed_identity_client_id=os.environ.get("FunctionApp__ClientId")
)
else:
credential = AzureKeyCredential(os.environ["AIService__Services__Key"])
credential = AzureKeyCredential(os.environ.get("AIService__Services__Key"))
text_analytics_client = TextAnalyticsClient(
endpoint=os.environ["AIService__Services__Endpoint"],
endpoint=os.environ.get("AIService__Services__Endpoint"),
credential=credential,
)

Expand Down
15 changes: 7 additions & 8 deletions ai_search_with_adi/adi_function_app/storage_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,21 @@
class StorageAccountHelper:
"""Helper class for interacting with Azure Blob Storage."""

def __init__(self) -> None:
"""Initialize the StorageAccountHelper class."""
self._endpoint = os.environ["StorageAccount__ConnectionString"]

async def get_client(self):
"""Get the BlobServiceClient object."""
if get_identity_type() == IdentityType.SYSTEM_ASSIGNED:
endpoint = os.environ.get("StorageAccount__Endpoint")
credential = DefaultAzureCredential()
return BlobServiceClient(account_url=self._endpoint, credential=credential)
return BlobServiceClient(account_url=endpoint, credential=credential)
elif get_identity_type() == IdentityType.USER_ASSIGNED:
endpoint = os.environ.get("StorageAccount__Endpoint")
credential = DefaultAzureCredential(
managed_identity_client_id=os.environ["FunctionApp__ClientId"]
managed_identity_client_id=os.environ.get("FunctionApp__ClientId")
)
return BlobServiceClient(account_url=self._endpoint, credential=credential)
return BlobServiceClient(account_url=endpoint, credential=credential)
else:
return BlobServiceClient(account_url=self._endpoint)
endpoint = os.environ.get("StorageAccount__ConnectionString")
return BlobServiceClient(account_url=endpoint)

async def add_metadata_to_blob(
self, source: str, container: str, metadata: dict
Expand Down

0 comments on commit 0634e24

Please sign in to comment.