Files
Sebastian Husch Lee 4edefe3e56 Feat: Support Azure Workload Identity Credential (#9012)
* Start adding support for passing callable to Azure components

* Add to chat version

* Fix test

* Add reno

* Add support to azure doc and text embedder

* Rename

* update llm metadata extractor

* Add tests for text embedder

* Update tests

* Remove unused fixture and import

* Update reno
2025-03-12 13:45:40 +01:00

17 lines
636 B
Python

# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
#
# SPDX-License-Identifier: Apache-2.0
from haystack.lazy_imports import LazyImport
with LazyImport(message="Run 'pip install azure-identity") as azure_import:
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
def default_azure_ad_token_provider() -> str:
"""
Get a Azure AD token using the DefaultAzureCredential and the "https://cognitiveservices.azure.com/.default" scope.
"""
azure_import.check()
return get_bearer_token_provider(DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default")()