def sample_authentication_api_key(): # [START create_dt_client_with_key] from azure.core.credentials import AzureKeyCredential from azure.ai.translation.document import DocumentTranslationClient endpoint = os.environ["AZURE_DOCUMENT_TRANSLATION_ENDPOINT"] key = os.environ["AZURE_DOCUMENT_TRANSLATION_KEY"] document_translation_client = DocumentTranslationClient(endpoint, AzureKeyCredential(key)) # [END create_dt_client_with_key] # make calls with authenticated client result = document_translation_client.get_supported_document_formats()
def sample_authentication_with_azure_active_directory(): # [START create_dt_client_with_aad] """DefaultAzureCredential will use the values from these environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET """ from azure.identity import DefaultAzureCredential from azure.ai.translation.document import DocumentTranslationClient endpoint = os.environ["AZURE_DOCUMENT_TRANSLATION_ENDPOINT"] credential = DefaultAzureCredential() document_translation_client = DocumentTranslationClient(endpoint, credential) # [END create_dt_client_with_aad] # make calls with authenticated client result = document_translation_client.get_supported_document_formats()