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.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group