cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Call Azure Cognitive Services API from Notebook using Azure Entra ID that is logged on to Databricks

herbblinebury
New Contributor II

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.

3 REPLIES 3

-werners-
Esteemed Contributor III

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.

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.

-werners-
Esteemed Contributor III

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.

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now