本页提供有关受支持的身份验证方法和客户端的信息,还介绍用于使用服务连接器将 Azure AI 服务连接到其他云服务的示例代码。 此页还列出了创建服务连接时获取的默认环境变量名称和值。
受支持的计算服务
服务连接器可用于将以下计算服务连接到 Azure AI 服务:
- Azure 应用程序服务
- Azure Container Apps
- Azure Functions
- Azure Kubernetes 服务 (AKS)
- Azure Spring Apps
受支持的身份验证类型和客户端类型
下表显示了使用服务连接器将计算服务连接到单个 Azure AI 服务时受支持的身份验证方法和客户端的组合。 “是”表示支持该组合,“否”表示不支持该组合。
客户端类型 |
系统分配的托管标识 |
用户分配的托管标识 |
机密/连接字符串 |
服务主体 |
.NET |
是 |
是 |
是 |
是 |
Java |
是 |
是 |
是 |
是 |
Node.js |
是 |
是 |
是 |
是 |
Python |
是 |
是 |
是 |
是 |
无 |
是 |
是 |
是 |
是 |
此表支持表中客户端类型和身份验证方法的所有组合都受到支持。 所有客户端类型都可通过服务连接器使用任何身份验证方法连接到 Azure AI 服务。
默认环境变量名称或应用程序属性和示例代码
使用以下连接详细信息将计算服务连接到 Azure AI 服务。 有关命名约定的详细信息,请参阅服务连接器深度解析一文。
系统分配的托管标识(推荐)
默认环境变量名称 |
说明 |
示例值 |
AZURE_AISERVICES_OPENAI_BASE |
Azure OpenAI 终结点 |
https://<your-Azure-AI-Services-endpoint>.openai.azure.com/ |
AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT |
Azure 认知服务令牌提供程序服务 |
https://<your-Azure-AI-Services-endpoint>.cognitiveservices.azure.com/ |
AZURE_AISERVICES_SPEECH_ENDPOINT |
语音转文本(标准)API 终结点 |
https://<___location>.stt.speech.microsoft.com |
代码示例
请参阅下面的步骤和代码,以使用系统分配的托管标识连接到 Azure AI 服务。
可以使用 Azure 客户端库访问 Azure AI 服务支持的各种认知 API。 本示例中以 Azure AI 文本分析为例。 请参阅对 Azure AI 服务的请求进行身份验证,以直接调用认知 API。
安装以下依赖项。 我们以 Azure.AI.TextAnalytics
为例。
dotnet add package Azure.AI.TextAnalytics
dotnet add package Azure.Identity
使用 Azure 标识库进行身份验证,并从服务连接器添加的环境变量中获取 Azure AI 服务终结点。 使用下面的代码时,请对要使用的身份验证类型的代码片段的一部分取消评论。
using Azure.AI.TextAnalytics;
using Azure.Identity;
string endpoint = Environment.GetEnvironmentVariable("AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT");
// Uncomment the following lines corresponding to the authentication type you want to use.
// system-assigned managed identity
// var credential = new DefaultAzureCredential();
// user-assigned managed identity
// var credential = new DefaultAzureCredential(
// new DefaultAzureCredentialOptions
// {
// ManagedIdentityClientId = Environment.GetEnvironmentVariable("AZURE_AISERVICES_CLIENTID");
// });
// service principal
// var tenantId = Environment.GetEnvironmentVariable("AZURE_AISERVICES_TENANTID");
// var clientId = Environment.GetEnvironmentVariable("AZURE_AISERVICES_CLIENTID");
// var clientSecret = Environment.GetEnvironmentVariable("AZURE_AISERVICES_CLIENTSECRET");
// var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
TextAnalyticsClient languageServiceClient = new(
new Uri(endpoint),
credential);
将以下依赖项添加到 pom.xml 文件。 我们以 azure-ai-textanalytics
为例。
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-textanalytics</artifactId>
<version>5.1.12</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.11.4</version>
</dependency>
使用 azure-identity
进行身份验证,并从服务连接器添加的环境变量中获取 Azure AI 服务终结点。 使用下面的代码时,请对要使用的身份验证类型的代码片段的一部分取消评论。
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-managed identity
// DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
// for user-assigned managed identity
// DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
// .managedIdentityClientId(System.getenv("AZURE_AISERVICES_CLIENTID"))
// .build();
// for service principal
// ClientSecretCredential credential = new ClientSecretCredentialBuilder()
// .clientId(System.getenv("AZURE_AISERVICES_CLIENTID"))
// .clientSecret(System.getenv("AZURE_AISERVICES_CLIENTSECRET"))
// .tenantId(System.getenv("AZURE_AISERVICES_TENANTID"))
// .build();
String endpoint = System.getenv("AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT");
TextAnalyticsClient languageClient = new TextAnalyticsClientBuilder()
.credential(credential)
.endpoint(endpoint)
.buildClient();
- 安装以下依赖项。 我们以
azure-ai-textanalytics
为例。
pip install azure-ai-textanalytics==5.1.0
pip install azure-identity
- 使用
azure-identity
进行身份验证,并从服务连接器添加的环境变量中获取 Azure AI 服务终结点。 使用下面的代码时,请对要使用的身份验证类型的代码片段的一部分取消评论。
import os
from azure.ai.textanalytics import TextAnalyticsClient
from azure.identity import ManagedIdentityCredential, ClientSecretCredential
# Uncomment the following lines corresponding to the authentication type you want to use.
# system-assigned managed identity
# cred = ManagedIdentityCredential()
# user-assigned managed identity
# managed_identity_client_id = os.getenv('AZURE_AISERVICES_CLIENTID')
# cred = ManagedIdentityCredential(client_id=managed_identity_client_id)
# service principal
# tenant_id = os.getenv('AZURE_AISERVICES_TENANTID')
# client_id = os.getenv('AZURE_AISERVICES_CLIENTID')
# client_secret = os.getenv('AZURE_AISERVICES_CLIENTSECRET')
# cred = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
endpoint = os.getenv('AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT')
language_service_client = TextAnalyticsClient(
endpoint=endpoint,
credential=cred)
安装以下依赖项。 我们以 ai-text-analytics
为例。
npm install @azure/ai-text-analytics@5.1.0
npm install @azure/identity
使用 @azure/identity
进行身份验证,并从服务连接器添加的环境变量中获取 Azure AI 服务终结点。 使用下面的代码时,请对要使用的身份验证类型的代码片段的一部分取消评论。
import { DefaultAzureCredential,ClientSecretCredential } from "@azure/identity";
const { TextAnalyticsClient } = require("@azure/ai-text-analytics");
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-assigned managed identity
// const credential = new DefaultAzureCredential();
// for user-assigned managed identity
// const clientId = process.env.AZURE_AISERVICES_CLIENTID;
// const credential = new DefaultAzureCredential({
// managedIdentityClientId: clientId
// });
// for service principal
// const tenantId = process.env.AZURE_AISERVICES_TENANTID;
// const clientId = process.env.AZURE_AISERVICES_CLIENTID;
// const clientSecret = process.env.AZURE_AISERVICES_CLIENTSECRET;
// const credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
const endpoint = process.env.AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT;
const languageClient = new TextAnalyticsClient(endpoint, credential);
用户分配的托管标识
默认环境变量名称 |
说明 |
示例值 |
AZURE_AISERVICES_OPENAI_BASE |
Azure OpenAI 终结点 |
https://<your-Azure-AI-Services-endpoint>.openai.azure.com/ |
AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT |
Azure 认知服务令牌提供程序服务 |
https://<your-Azure-AI-Services-endpoint>.cognitiveservices.azure.com/ |
AZURE_AISERVICES_SPEECH_ENDPOINT |
语音转文本(标准)API 终结点 |
https://<___location>.stt.speech.microsoft.com |
AZURE_AISERVICES_CLIENTID |
客户端 ID |
<client-ID> |
代码示例
请参阅下面的步骤和代码,以使用用户分配的托管标识连接到 Azure AI 服务。
可以使用 Azure 客户端库访问 Azure AI 服务支持的各种认知 API。 本示例中以 Azure AI 文本分析为例。 请参阅对 Azure AI 服务的请求进行身份验证,以直接调用认知 API。
安装以下依赖项。 我们以 Azure.AI.TextAnalytics
为例。
dotnet add package Azure.AI.TextAnalytics
dotnet add package Azure.Identity
使用 Azure 标识库进行身份验证,并从服务连接器添加的环境变量中获取 Azure AI 服务终结点。 使用下面的代码时,请对要使用的身份验证类型的代码片段的一部分取消评论。
using Azure.AI.TextAnalytics;
using Azure.Identity;
string endpoint = Environment.GetEnvironmentVariable("AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT");
// Uncomment the following lines corresponding to the authentication type you want to use.
// system-assigned managed identity
// var credential = new DefaultAzureCredential();
// user-assigned managed identity
// var credential = new DefaultAzureCredential(
// new DefaultAzureCredentialOptions
// {
// ManagedIdentityClientId = Environment.GetEnvironmentVariable("AZURE_AISERVICES_CLIENTID");
// });
// service principal
// var tenantId = Environment.GetEnvironmentVariable("AZURE_AISERVICES_TENANTID");
// var clientId = Environment.GetEnvironmentVariable("AZURE_AISERVICES_CLIENTID");
// var clientSecret = Environment.GetEnvironmentVariable("AZURE_AISERVICES_CLIENTSECRET");
// var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
TextAnalyticsClient languageServiceClient = new(
new Uri(endpoint),
credential);
将以下依赖项添加到 pom.xml 文件。 我们以 azure-ai-textanalytics
为例。
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-textanalytics</artifactId>
<version>5.1.12</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.11.4</version>
</dependency>
使用 azure-identity
进行身份验证,并从服务连接器添加的环境变量中获取 Azure AI 服务终结点。 使用下面的代码时,请对要使用的身份验证类型的代码片段的一部分取消评论。
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-managed identity
// DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
// for user-assigned managed identity
// DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
// .managedIdentityClientId(System.getenv("AZURE_AISERVICES_CLIENTID"))
// .build();
// for service principal
// ClientSecretCredential credential = new ClientSecretCredentialBuilder()
// .clientId(System.getenv("AZURE_AISERVICES_CLIENTID"))
// .clientSecret(System.getenv("AZURE_AISERVICES_CLIENTSECRET"))
// .tenantId(System.getenv("AZURE_AISERVICES_TENANTID"))
// .build();
String endpoint = System.getenv("AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT");
TextAnalyticsClient languageClient = new TextAnalyticsClientBuilder()
.credential(credential)
.endpoint(endpoint)
.buildClient();
- 安装以下依赖项。 我们以
azure-ai-textanalytics
为例。
pip install azure-ai-textanalytics==5.1.0
pip install azure-identity
- 使用
azure-identity
进行身份验证,并从服务连接器添加的环境变量中获取 Azure AI 服务终结点。 使用下面的代码时,请对要使用的身份验证类型的代码片段的一部分取消评论。
import os
from azure.ai.textanalytics import TextAnalyticsClient
from azure.identity import ManagedIdentityCredential, ClientSecretCredential
# Uncomment the following lines corresponding to the authentication type you want to use.
# system-assigned managed identity
# cred = ManagedIdentityCredential()
# user-assigned managed identity
# managed_identity_client_id = os.getenv('AZURE_AISERVICES_CLIENTID')
# cred = ManagedIdentityCredential(client_id=managed_identity_client_id)
# service principal
# tenant_id = os.getenv('AZURE_AISERVICES_TENANTID')
# client_id = os.getenv('AZURE_AISERVICES_CLIENTID')
# client_secret = os.getenv('AZURE_AISERVICES_CLIENTSECRET')
# cred = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
endpoint = os.getenv('AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT')
language_service_client = TextAnalyticsClient(
endpoint=endpoint,
credential=cred)
安装以下依赖项。 我们以 ai-text-analytics
为例。
npm install @azure/ai-text-analytics@5.1.0
npm install @azure/identity
使用 @azure/identity
进行身份验证,并从服务连接器添加的环境变量中获取 Azure AI 服务终结点。 使用下面的代码时,请对要使用的身份验证类型的代码片段的一部分取消评论。
import { DefaultAzureCredential,ClientSecretCredential } from "@azure/identity";
const { TextAnalyticsClient } = require("@azure/ai-text-analytics");
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-assigned managed identity
// const credential = new DefaultAzureCredential();
// for user-assigned managed identity
// const clientId = process.env.AZURE_AISERVICES_CLIENTID;
// const credential = new DefaultAzureCredential({
// managedIdentityClientId: clientId
// });
// for service principal
// const tenantId = process.env.AZURE_AISERVICES_TENANTID;
// const clientId = process.env.AZURE_AISERVICES_CLIENTID;
// const clientSecret = process.env.AZURE_AISERVICES_CLIENTSECRET;
// const credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
const endpoint = process.env.AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT;
const languageClient = new TextAnalyticsClient(endpoint, credential);
连接字符串
默认环境变量名称 |
说明 |
示例值 |
AZURE_AISERVICES_OPENAI_BASE |
Azure OpenAI 终结点 |
https://<your-Azure-AI-Services-endpoint>.openai.azure.com/ |
AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT |
Azure 认知服务令牌提供程序服务 |
https://<your-Azure-AI-Services-endpoint>.cognitiveservices.azure.com/ |
AZURE_AISERVICES_SPEECH_ENDPOINT |
语音转文本(标准)API 终结点 |
https://<___location>.stt.speech.microsoft.com |
AZURE_AISERVICES_KEY |
Azure AI 服务 API 密钥 |
<api-key> |
代码示例
请参阅下面的步骤和代码,以使用连接字符串连接到 Azure AI 服务。
可以使用 Azure 客户端库访问 Azure AI 服务支持的各种认知 API。 本示例中以 Azure AI 文本分析为例。 请参阅对 Azure AI 服务的请求进行身份验证,以直接调用认知 API。
安装以下依赖项。 我们以 Azure.AI.TextAnalytics
为例。
dotnet add package Azure.AI.TextAnalytics
dotnet add package Azure.Core --version 1.40.0
从服务连接器添加的环境变量中获取 Azure AI 服务终结点和密钥。
using Azure.AI.TextAnalytics;
string endpoint = Environment.GetEnvironmentVariable("AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT")
string key = Environment.GetEnvironmentVariable("AZURE_AISERVICES_KEY");
TextAnalyticsClient languageServiceClient = new(
new Uri(endpoint),
new AzureKeyCredential(key));
- 将以下依赖项添加到 pom.xml 文件。 我们以
azure-ai-textanalytics
为例。
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.49.1</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-textanalytics</artifactId>
<version>5.1.12</version>
</dependency>
- 从服务连接器添加的环境变量中获取 Azure AI 服务终结点和密钥。
String endpoint = System.getenv("AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT");
String key = System.getenv("AZURE_AISERVICES_KEY");
TextAnalyticsClient languageClient = new TextAnalyticsClientBuilder()
.credential(new AzureKeyCredential(key))
.endpoint(endpoint)
.buildClient();
- 安装以下依赖项。 我们以
azure-ai-textanalytics
为例。
pip install azure-ai-textanalytics==5.1.0
pip install azure-core
- 从服务连接器添加的环境变量中获取 Azure AI 服务终结点和密钥。
import os
from azure.ai.textanalytics import TextAnalyticsClient
from azure.core.credentials import AzureKeyCredential
key = os.environ['AZURE_AISERVICES_KEY']
endpoint = os.environ['AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT']
language_service_client = TextAnalyticsClient(
endpoint=retrieved_endpoint,
credential=AzureKeyCredential(key))
安装以下依赖项。 我们以 ai-text-analytics
为例。
npm install @azure/ai-text-analytics@5.1.0
从服务连接器添加的环境变量中获取 Azure AI 服务终结点和密钥。
const { TextAnalyticsClient, AzureKeyCredential } = require("@azure/ai-text-analytics");
const endpoint = process.env.AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT;
const credential = new AzureKeyCredential(process.env.AZURE_AISERVICES_KEY);
const languageClient = new TextAnalyticsClient(endpoint, credential);
服务主体
默认环境变量名称 |
说明 |
示例值 |
AZURE_AISERVICES_OPENAI_BASE |
Azure OpenAI 终结点 |
https://<your-Azure-AI-Services-endpoint>.openai.azure.com/ |
AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT |
Azure 认知服务令牌提供程序服务 |
https://<your-Azure-AI-Services-endpoint>.cognitiveservices.azure.com/ |
AZURE_AISERVICES_SPEECH_ENDPOINT |
语音转文本(标准)API 终结点 |
https://<___location>.stt.speech.microsoft.com |
AZURE_AISERVICES_CLIENTID |
客户端 ID |
<client-ID> |
AZURE_AISERVICES_CLIENTSECRET |
客户端密码 |
<client-secret> |
AZURE_AISERVICES_TENANTID |
租户 ID |
<tenant-ID> |
代码示例
请参阅下面的步骤和代码,以使用服务主体连接到 Azure AI 服务。
可以使用 Azure 客户端库访问 Azure AI 服务支持的各种认知 API。 本示例中以 Azure AI 文本分析为例。 请参阅对 Azure AI 服务的请求进行身份验证,以直接调用认知 API。
安装以下依赖项。 我们以 Azure.AI.TextAnalytics
为例。
dotnet add package Azure.AI.TextAnalytics
dotnet add package Azure.Identity
使用 Azure 标识库进行身份验证,并从服务连接器添加的环境变量中获取 Azure AI 服务终结点。 使用下面的代码时,请对要使用的身份验证类型的代码片段的一部分取消评论。
using Azure.AI.TextAnalytics;
using Azure.Identity;
string endpoint = Environment.GetEnvironmentVariable("AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT");
// Uncomment the following lines corresponding to the authentication type you want to use.
// system-assigned managed identity
// var credential = new DefaultAzureCredential();
// user-assigned managed identity
// var credential = new DefaultAzureCredential(
// new DefaultAzureCredentialOptions
// {
// ManagedIdentityClientId = Environment.GetEnvironmentVariable("AZURE_AISERVICES_CLIENTID");
// });
// service principal
// var tenantId = Environment.GetEnvironmentVariable("AZURE_AISERVICES_TENANTID");
// var clientId = Environment.GetEnvironmentVariable("AZURE_AISERVICES_CLIENTID");
// var clientSecret = Environment.GetEnvironmentVariable("AZURE_AISERVICES_CLIENTSECRET");
// var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
TextAnalyticsClient languageServiceClient = new(
new Uri(endpoint),
credential);
将以下依赖项添加到 pom.xml 文件。 我们以 azure-ai-textanalytics
为例。
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-textanalytics</artifactId>
<version>5.1.12</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.11.4</version>
</dependency>
使用 azure-identity
进行身份验证,并从服务连接器添加的环境变量中获取 Azure AI 服务终结点。 使用下面的代码时,请对要使用的身份验证类型的代码片段的一部分取消评论。
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-managed identity
// DefaultAzureCredential credential = new DefaultAzureCredentialBuilder().build();
// for user-assigned managed identity
// DefaultAzureCredential credential = new DefaultAzureCredentialBuilder()
// .managedIdentityClientId(System.getenv("AZURE_AISERVICES_CLIENTID"))
// .build();
// for service principal
// ClientSecretCredential credential = new ClientSecretCredentialBuilder()
// .clientId(System.getenv("AZURE_AISERVICES_CLIENTID"))
// .clientSecret(System.getenv("AZURE_AISERVICES_CLIENTSECRET"))
// .tenantId(System.getenv("AZURE_AISERVICES_TENANTID"))
// .build();
String endpoint = System.getenv("AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT");
TextAnalyticsClient languageClient = new TextAnalyticsClientBuilder()
.credential(credential)
.endpoint(endpoint)
.buildClient();
- 安装以下依赖项。 我们以
azure-ai-textanalytics
为例。
pip install azure-ai-textanalytics==5.1.0
pip install azure-identity
- 使用
azure-identity
进行身份验证,并从服务连接器添加的环境变量中获取 Azure AI 服务终结点。 使用下面的代码时,请对要使用的身份验证类型的代码片段的一部分取消评论。
import os
from azure.ai.textanalytics import TextAnalyticsClient
from azure.identity import ManagedIdentityCredential, ClientSecretCredential
# Uncomment the following lines corresponding to the authentication type you want to use.
# system-assigned managed identity
# cred = ManagedIdentityCredential()
# user-assigned managed identity
# managed_identity_client_id = os.getenv('AZURE_AISERVICES_CLIENTID')
# cred = ManagedIdentityCredential(client_id=managed_identity_client_id)
# service principal
# tenant_id = os.getenv('AZURE_AISERVICES_TENANTID')
# client_id = os.getenv('AZURE_AISERVICES_CLIENTID')
# client_secret = os.getenv('AZURE_AISERVICES_CLIENTSECRET')
# cred = ClientSecretCredential(tenant_id=tenant_id, client_id=client_id, client_secret=client_secret)
endpoint = os.getenv('AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT')
language_service_client = TextAnalyticsClient(
endpoint=endpoint,
credential=cred)
安装以下依赖项。 我们以 ai-text-analytics
为例。
npm install @azure/ai-text-analytics@5.1.0
npm install @azure/identity
使用 @azure/identity
进行身份验证,并从服务连接器添加的环境变量中获取 Azure AI 服务终结点。 使用下面的代码时,请对要使用的身份验证类型的代码片段的一部分取消评论。
import { DefaultAzureCredential,ClientSecretCredential } from "@azure/identity";
const { TextAnalyticsClient } = require("@azure/ai-text-analytics");
// Uncomment the following lines corresponding to the authentication type you want to use.
// for system-assigned managed identity
// const credential = new DefaultAzureCredential();
// for user-assigned managed identity
// const clientId = process.env.AZURE_AISERVICES_CLIENTID;
// const credential = new DefaultAzureCredential({
// managedIdentityClientId: clientId
// });
// for service principal
// const tenantId = process.env.AZURE_AISERVICES_TENANTID;
// const clientId = process.env.AZURE_AISERVICES_CLIENTID;
// const clientSecret = process.env.AZURE_AISERVICES_CLIENTSECRET;
// const credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
const endpoint = process.env.AZURE_AISERVICES_COGNITIVESERVICES_ENDPOINT;
const languageClient = new TextAnalyticsClient(endpoint, credential);
相关内容