Skip to content

Commit c28db6d

Browse files
Merge pull request #250496 from laujan/114210-github-issue-translator-authentication
update authentication guidance
2 parents 9493788 + aa8eb2d commit c28db6d

File tree

7 files changed

+37
-9
lines changed

7 files changed

+37
-9
lines changed

articles/ai-services/translator/create-translator-resource.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
title: Create a Translator resource
33
titleSuffix: Azure AI services
4-
description: This article shows you how to create an Azure AI Translator resource and retrieve yourgit key and endpoint URL.
4+
description: This article shows you how to create an Azure AI Translator resource.
55
services: cognitive-services
66
author: laujan
77
ms.author: lajanuar
88
manager: nitinme
99
ms.service: cognitive-services
1010
ms.subservice: translator-text
1111
ms.topic: how-to
12-
ms.date: 07/18/2023
12+
ms.date: 09/06/2023
1313
---
1414

1515
# Create a Translator resource
@@ -46,7 +46,7 @@ The Translator service can be accessed through two different resource types:
4646
* Each subscription has a free tier.
4747
* The free tier has the same features and functionality as the paid plans and doesn't expire.
4848
* Only one free tier is available per subscription.
49-
* Document Translation is supported in paid tiers. The Language Studio only supports the S1 or D3 instance tiers. We suggest you select the Standard S1 instance tier to try Document Translation.
49+
* Document Translation is supported in paid tiers. The Language Studio only supports the S1 or D3 instance tiers. We suggest you select the Standard S1 instance tier to try Document Translation.
5050

5151
1. If you've created a multi-service resource, you need to confirm more usage details via the check boxes.
5252

@@ -72,6 +72,24 @@ All Azure AI services API requests require an endpoint URL and a read-only key f
7272

7373
:::image type="content" source="media/keys-and-endpoint-resource.png" alt-text="Get key and endpoint.":::
7474

75+
## Create a Text Translation client
76+
77+
Text Translation supports both [global and regional endpoints](#complete-your-project-and-instance-details). Once you have your [authentication keys](#authentication-keys-and-endpoint-url), you need to create an instance of the `TextTranslationClient`, using an `AzureKeyCredential` for authentication, to interact with the Text Translation service:
78+
79+
* To create a `TextTranslationClient` using a global resource endpoint, you need your resource **API key**:
80+
81+
```bash
82+
AzureKeyCredential credential = new('<apiKey>');
83+
TextTranslationClient client = new(credential);
84+
```
85+
86+
* To create a `TextTranslationClient` using a regional resource endpoint, you need your resource **API key** and the name of the **region** where your resource is located:
87+
88+
```bash
89+
AzureKeyCredential credential = new('<apiKey>');
90+
TextTranslationClient client = new(credential, '<region>');
91+
```
92+
7593
## How to delete a resource or resource group
7694

7795
> [!WARNING]

articles/ai-services/translator/includes/text-translation-sdk/csharp.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ To interact with the Translator service using the client library, you need to cr
7171
7272
**Translate text**
7373

74-
```csharp
74+
> [!NOTE]
75+
> In this example we are using the global endpoint. If you're using a regional endpoint, see [Create a Text Translation client](../../create-translator-resource.md#create-a-text-translation-client).
7576
76-
// Using the global endpoint (default)
77+
```csharp
7778

7879
using Azure;
7980
using Azure.AI.Translation.Text;

articles/ai-services/translator/includes/text-translation-sdk/java.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ For this quickstart, we use the Gradle build automation tool to create and run t
113113

114114
To interact with the Translator service using the client library, you need to create an instance of the `TextTranslationClient`class. To do so, create an `AzureKeyCredential` with your `key` from the Azure portal and a `TextTranslationClient` instance with the `AzureKeyCredential`. The authentication varies slightly depending on whether your resource uses the regional or global endpoint. For this project, authenticate using the global endpoint. For more information about using a regional endpoint, _see_ [Translator text sdks](../../text-sdk-overview.md#3-authenticate-the-client).
115115

116+
> [!NOTE]
117+
> In this example we are using the global endpoint. If you're using a regional endpoint, see [Create a Text Translation client](../../create-translator-resource.md#create-a-text-translation-client).
118+
116119
```java
117120
import java.util.List;
118121
import java.util.ArrayList;

articles/ai-services/translator/includes/text-translation-sdk/javascript.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ To interact with the Translator service using the client library, you need to cr
7777
7878
**Translate text**
7979

80+
> [!NOTE]
81+
> In this example we are using a regional endpoint. If you're using the global endpoint, see [Create a Text Translation client](../../create-translator-resource.md#create-a-text-translation-client).
82+
8083
```javascript
8184
const TextTranslationClient = require("@azure-rest/ai-translation-text").default
8285

articles/ai-services/translator/includes/text-translation-sdk/python.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ To interact with the Translator service using the client library, you need to cr
4141

4242
**Translate text**
4343

44+
> [!NOTE]
45+
> In this example we are using a regional endpoint. If you're using the global endpoint, see [Create a Text Translation client](../../create-translator-resource.md#create-a-text-translation-client).
46+
4447
```python
4548
from azure.ai.translation.text import TextTranslationClient, TranslatorCredential
4649
from azure.ai.translation.text.models import InputTextItem

articles/ai-services/translator/quickstart-text-rest-api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: translator-text
1010
ms.topic: quickstart
11-
ms.date: 07/18/2023
11+
ms.date: 09/06/2023
1212
ms.author: lajanuar
1313
ms.devlang: csharp, golang, java, javascript, python
1414
ms.custom: devx-track-python
@@ -41,7 +41,7 @@ You need an active Azure subscription. If you don't have an Azure subscription,
4141
> * For this quickstart it is recommended that you use a Translator text single-service global resource.
4242
> * With a single-service global resource you'll include one authorization header (**Ocp-Apim-Subscription-key**) with the REST API request. The value for Ocp-Apim-Subscription-key is your Azure secret key for your Translator Text subscription.
4343
> * If you choose to use an Azure AI multi-service or regional Translator resource, two authentication headers will be required: (**Ocp-Api-Subscription-Key** and **Ocp-Apim-Subscription-Region**). The value for Ocp-Apim-Subscription-Region is the region associated with your subscription.
44-
> * For more information on how to use the **Ocp-Apim-Subscription-Region** header, _see_ [Text Translation REST API headers](translator-text-apis.md).
44+
> * For more information on how to use the **Ocp-Apim-Subscription-Region** header, _see_ [Text Translation REST API headers](translator-text-apis.md#headers).
4545
4646
<!-- checked -->
4747
<!--

articles/ai-services/translator/quickstart-text-sdk.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ manager: nitinme
88
ms.service: cognitive-services
99
ms.subservice: translator-text
1010
ms.topic: quickstart
11-
ms.date: 07/18/2023
11+
ms.date: 09/06/2023
1212
ms.author: lajanuar
1313
ms.devlang: csharp, java, javascript, python
1414
ms.custom: mode-other, devx-track-dotnet, devx-track-extended-java, devx-track-js, devx-track-python
@@ -33,7 +33,7 @@ In this quickstart, get started using the Translator service to [translate text]
3333

3434
You need an active Azure subscription. If you don't have an Azure subscription, you can [create one for free](https://azure.microsoft.com/free/cognitive-services/)
3535

36-
* Once you have your Azure subscription, create a [Translator resource](https://portal.azure.com/#create/Microsoft.CognitiveServicesTextTranslation) in the Azure portal.
36+
* Once you have your Azure subscription, create a [Translator resource](create-translator-resource.md) in the [Azure portal](https://portal.azure.com/#create/Microsoft.CognitiveServicesTextTranslation).
3737

3838
* After your resource deploys, select **Go to resource** and retrieve your key and endpoint.
3939

0 commit comments

Comments
 (0)