시스템이 할당한 관리 ID를 사용하여 Azure AI 서비스에 연결하려면 아래 단계와 코드를 참조하세요.
Azure 클라이언트 라이브러리를 사용하여 Azure AI 서비스에서 지원하는 다양한 인식 API에 액세스할 수 있습니다. 이 샘플에서는 Azure AI Text Analytics를 예로 사용합니다. 인식 API를 직접 호출하려면 Azure AI 서비스에 대한 요청 인증을 참조하세요.
Azure ID 라이브러리를 사용하여 인증하고 서비스 커넥터에서 추가한 환경 변수에서 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를 예제로 사용합니다.
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();
사용자가 할당한 관리 ID를 사용하여 Azure AI 서비스에 연결하려면 아래 단계와 코드를 참조하세요.
Azure 클라이언트 라이브러리를 사용하여 Azure AI 서비스에서 지원하는 다양한 인식 API에 액세스할 수 있습니다. 이 샘플에서는 Azure AI Text Analytics를 예로 사용합니다. 인식 API를 직접 호출하려면 Azure AI 서비스에 대한 요청 인증을 참조하세요.
Azure ID 라이브러리를 사용하여 인증하고 서비스 커넥터에서 추가한 환경 변수에서 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를 예제로 사용합니다.
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 서비스에 연결하려면 아래 단계와 코드를 참조하세요.
Azure 클라이언트 라이브러리를 사용하여 Azure AI 서비스에서 지원하는 다양한 인식 API에 액세스할 수 있습니다. 이 샘플에서는 Azure AI Text Analytics를 예로 사용합니다. 인식 API를 직접 호출하려면 Azure AI 서비스에 대한 요청 인증을 참조하세요.
서비스 주체를 사용하여 Azure AI 서비스에 연결하려면 아래 단계와 코드를 참조하세요.
Azure 클라이언트 라이브러리를 사용하여 Azure AI 서비스에서 지원하는 다양한 인식 API에 액세스할 수 있습니다. 이 샘플에서는 Azure AI Text Analytics를 예로 사용합니다. 인식 API를 직접 호출하려면 Azure AI 서비스에 대한 요청 인증을 참조하세요.
Azure ID 라이브러리를 사용하여 인증하고 서비스 커넥터에서 추가한 환경 변수에서 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를 예제로 사용합니다.
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();