Call Azure Cognitive Services API from Notebook using Azure Entra ID that is logged on to Databricks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 07:50 AM
I would like to call Azure Cognitive Services API from Notebook using Azure Entra ID that is logged on to Databricks. The cognitive services key is not available as local authentication for cognitive services is not enables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 04:27 AM
I have not done this, but as with any api you call programmatically, you will have to do the authentication first (using code in the notebook), then store the token (or whatever auth method you use) and do the actual call.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 05:10 AM
Thanks for the response. I am encountering an error when I attempt to obtain a credential from the databricks notebook:
Example:
from azure.identity import DefaultAzureCredential
import requests
# Initialize DefaultAzureCredential
credential = DefaultAzureCredential()
# Get a token for Cognitive Services (Text Analytics, for example)
token = credential.get_token("https://**My Language Service Name**.cognitiveservices.azure.com/.default")
DefaultAzureCredential failed to retrieve a token from the included credentials.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 05:23 AM
and what if you do not use a token but pass the credential in the cognitive services client (like Text Analytics Client)?
It could also be a networking/firewall setting that prevents you from calling ACS.
Permissions can also be the cause.

