Skip to content

Commit 37fde01

Browse files
authored
Merge pull request #107388 from swmachan/master
Updates related to JEDI
2 parents 246c724 + 693b8f3 commit 37fde01

File tree

3 files changed

+95
-23
lines changed

3 files changed

+95
-23
lines changed

articles/azure-government/documentation-government-cognitiveservices.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,10 @@ For more information, please see [public documentation](../cognitive-services/Fa
623623
624624
### Variations
625625
* The URI for accessing the Text Translation API in Azure Government is:
626-
- `https://dev.microsofttranslator.us/translate?api-version=3.0`
627-
### Text Translation Method
628-
This sample will use the [Text Translation - Translate method](../cognitive-services/translator/reference/v3-0-translate.md) to translate a string of text from a language into another specified language. There are multiple [language codes](https://api.cognitive.microsofttranslator.com/languages?api-version=3.0&scope=translation,dictionary,transliteration) that can be used with the Text Translation API.
626+
- `https://api.cognitive.microsofttranslator.us`
627+
* There are 2 regions `USGovVirginia` and `USGovArizona`
628+
### Text Translation Method
629+
The below example uses [Text Translation - Translate method](../cognitive-services/translator/reference/v3-0-translate.md) to translate a string of text from a language into another specified language. There are multiple [language codes](https://api.cognitive.microsofttranslator.com/languages?api-version=3.0&scope=translation) that can be used with the Text Translation API.
629630

630631
### Text Translation C# example request
631632

@@ -634,8 +635,9 @@ The sample is written in C#.
634635
1. Create a new Console solution in Visual Studio.
635636
2. Replace Program.cs with the corresponding code below.
636637
3. Replace the `subscriptionKey` value with the key value that you retrieved above.
637-
4. Replace the `text` value with text that you want to translate.
638-
5. Run the program.
638+
4. Replace the `region` value with the region value where you created your translator resource.
639+
5. Replace the `text` value with text that you want to translate.
640+
6. Run the program.
639641

640642
You can also test out different languages and texts by replacing the "text", "from", and "to" variables in Program.cs.
641643

@@ -657,7 +659,7 @@ namespace TextTranslator
657659
{
658660
class Program
659661
{
660-
static string host = "https://dev.microsofttranslator.us";
662+
static string host = "https://api.cognitive.microsofttranslator.us";
661663
static string path = "/translate?api-version=3.0";
662664
// Translate to German.
663665
static string params_ = "&to=de";
@@ -666,7 +668,10 @@ namespace TextTranslator
666668

667669
// NOTE: Replace this example key with a valid subscription key.
668670
static string key = "PASTE KEY HERE";
669-
671+
672+
// NOTE: Replace this example region with a valid region.
673+
static string region = "PASTE REGION HERE";
674+
670675
static string text = "Hello world!";
671676

672677
async static void Translate()
@@ -681,6 +686,7 @@ namespace TextTranslator
681686
request.RequestUri = new Uri(uri);
682687
request.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
683688
request.Headers.Add("Ocp-Apim-Subscription-Key", key);
689+
request.Headers.Add("Ocp-Apim-Subscription-Region", region);
684690

685691
var response = await client.SendAsync(request);
686692
var responseBody = await response.Content.ReadAsStringAsync();

articles/azure-government/documentation-government-services-aiandcognitiveservices.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ See details of supported locales by features in [Language and region support for
113113
Variations in Azure Government:
114114

115115
- Endpoint: https://api.cognitive.microsofttranslator.us
116-
- Auth Token Service: https://virginia.api.cognitive.microsoft.us/sts/v1.0/issueToken
116+
- Auth Token Service:
117+
- https://usgovvirginia.api.cognitive.microsoft.us/sts/v1.0/issueToken
118+
- https://usgovarizona.api.cognitive.microsoft.us/sts/v1.0/issueToken
117119
- Available SKUs: S1
118120
- Custom Translator and Translator Hub are not supported.
119121

articles/cognitive-services/Translator/reference/v3-0-reference.md

Lines changed: 79 additions & 15 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: reference
11-
ms.date: 11/14/2019
11+
ms.date: 3/13/2020
1212
ms.author: swmachan
1313
---
1414

@@ -53,17 +53,74 @@ There are three headers that you can use to authenticate your subscription. This
5353
|:----|:----|
5454
|Ocp-Apim-Subscription-Key|*Use with Cognitive Services subscription if you are passing your secret key*.<br/>The value is the Azure secret key for your subscription to Translator Text API.|
5555
|Authorization|*Use with Cognitive Services subscription if you are passing an authentication token.*<br/>The value is the Bearer token: `Bearer <token>`.|
56-
|Ocp-Apim-Subscription-Region|*Use with Cognitive Services multi-service subscription if you are passing a multi-service secret key.*<br/>The value is the region of the multi-service subscription. This value is optional when not using a multi-service subscription.|
56+
|Ocp-Apim-Subscription-Region|*Use with Cognitive Services multi-service and regional translator resource.*<br/>The value is the region of the multi-service or regional translator resource. This value is optional when using a global translator resource.|
5757

5858
### Secret key
5959
The first option is to authenticate using the `Ocp-Apim-Subscription-Key` header. Add the `Ocp-Apim-Subscription-Key: <YOUR_SECRET_KEY>` header to your request.
6060

61-
### Authorization token
61+
#### Authenticating with a global resource
62+
63+
When you use a [global translator resource](https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesTextTranslation), you need to include one header to call the translator API.
64+
65+
|Headers|Description|
66+
|:-----|:----|
67+
|Ocp-Apim-Subscription-Key| The value is the Azure secret key for your subscription to Translator Text API.|
68+
69+
Here's an example request to call the Translator API using the global translator resource
70+
71+
```curl
72+
// Pass secret key using headers
73+
curl -X POST "https://api.cognitive.microsoft.com/translate?api-version=3.0&to=es" \
74+
-H "Ocp-Apim-Subscription-Key:<your-key>" \
75+
-H "Content-Type: application/json" \
76+
-d "[{'Text':'Hello, what is your name?'}]"
77+
```
78+
79+
#### Authenticating with a regional resource
80+
81+
When you use a [regional translator resource](https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesTextTranslation).
82+
There are 2 headers that you need to call the translator API.
83+
84+
|Headers|Description|
85+
|:-----|:----|
86+
|Ocp-Apim-Subscription-Key| The value is the Azure secret key for your subscription to Translator Text API.|
87+
|Ocp-Apim-Subscription-Region| The value is the region of the translator resource. |
88+
89+
Here's an example request to call the Translator API using the regional translator resource
90+
91+
```curl
92+
// Pass secret key and region using headers
93+
curl -X POST "https://api.cognitive.microsoft.com/translate?api-version=3.0&to=es" \
94+
-H "Ocp-Apim-Subscription-Key:<your-key>" \
95+
-H "Ocp-Apim-Subscription-Region:<your-region>" \
96+
-H "Content-Type: application/json" \
97+
-d "[{'Text':'Hello, what is your name?'}]"
98+
```
99+
100+
#### Authenticating with a Multi-service resource
101+
102+
When you use a Cognitive Service’s multi-service resource. This allows you to use a single secret key to authenticate requests for multiple services.
103+
104+
When you use a multi-service secret key, you must include two authentication headers with your request. There are 2 headers that you need to call the translator API.
105+
106+
|Headers|Description|
107+
|:-----|:----|
108+
|Ocp-Apim-Subscription-Key| The value is the Azure secret key for your multi-service resource.|
109+
|Ocp-Apim-Subscription-Region| The value is the region of the multi-service resource. |
110+
111+
Region is required for the multi-service Text API subscription. The region you select is the only region that you can use for text translation when using the multi-service subscription key, and must be the same region you selected when you signed up for your multi-service subscription through the Azure portal.
112+
113+
Available regions are `australiaeast`, `brazilsouth`, `canadacentral`, `centralindia`, `centralus`, `centraluseuap`, `eastasia`, `eastus`, `eastus2`, `francecentral`, `japaneast`, `japanwest`, `koreacentral`, `northcentralus`, `northeurope`, `southcentralus`, `southeastasia`, `uksouth`, `westcentralus`, `westeurope`, `westus`, `westus2`, and `southafricanorth`.
114+
115+
If you pass the secret key in the query string with the parameter `Subscription-Key`, then you must specify the region with query parameter `Subscription-Region`.
116+
117+
### Authenticating with an access token
62118
Alternatively, you can exchange your secret key for an access token. This token is included with each request as the `Authorization` header. To obtain an authorization token, make a `POST` request to the following URL:
63119

64-
| Environment | Authentication service URL |
120+
| Resource type | Authentication service URL |
65121
|-----------------|-----------------------------------------------------------|
66-
| Azure | `https://api.cognitive.microsoft.com/sts/v1.0/issueToken` |
122+
| Global | `https://api.cognitive.microsoft.com/sts/v1.0/issueToken` |
123+
| Regional or Multi-Service | `https://<your-region>.api.cognitive.microsoft.com/sts/v1.0/issueToken` |
67124

68125
Here are example requests to obtain a token given a secret key:
69126

@@ -83,22 +140,29 @@ Authorization: Bearer <Base64-access_token>
83140

84141
An authentication token is valid for 10 minutes. The token should be reused when making multiple calls to the Translator APIs. However, if your program makes requests to the Translator API over an extended period of time, then your program must request a new access token at regular intervals (for example, every 8 minutes).
85142

86-
### Multi-service subscription
87-
88-
The last authentication option is to use a Cognitive Service’s multi-service subscription. This allows you to use a single secret key to authenticate requests for multiple services.
143+
## Virtual Network support
89144

90-
When you use a multi-service secret key, you must include two authentication headers with your request. The first passes the secret key, the second specifies the region associated with your subscription.
91-
* `Ocp-Apim-Subscription-Key`
92-
* `Ocp-Apim-Subscription-Region`
145+
Translator service is now available with Virtual Network capabilities in limited regions (`WestUS2`, `EastUS`, `SouthCentralUS`, `WestUS`, `Central US EUAP`, `global`). To enable Virtual Network, please see [Configuring Azure Cognitive Services Virtual Networks](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-virtual-networks?tabs=portal).
93146

94-
Region is required for the multi-service Text API subscription. The region you select is the only region that you can use for text translation when using the multi-service subscription key, and must be the same region you selected when you signed up for your multi-service subscription through the Azure portal.
147+
Once you turn on this capability, you must use the custom endpoint to call the Translator API. You cannot use the global translator endpoint ("api.cognitive.microsofttranslator.com") and you cannot authenticate with an access token.
95148

96-
Available regions are `australiaeast`, `brazilsouth`, `canadacentral`, `centralindia`, `centralus`, `centraluseuap`, `eastasia`, `eastus`, `eastus2`, `francecentral`, `japaneast`, `japanwest`, `koreacentral`, `northcentralus`, `northeurope`, `southcentralus`, `southeastasia`, `uksouth`, `westcentralus`, `westeurope`, `westus`, `westus2`, and `southafricanorth`.
149+
You can find the custom endpoint once you create the [translator resource](https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesTextTranslation).
97150

98-
If you pass the secret key in the query string with the parameter `Subscription-Key`, then you must specify the region with query parameter `Subscription-Region`.
151+
|Headers|Description|
152+
|:-----|:----|
153+
|Ocp-Apim-Subscription-Key| The value is the Azure secret key for your subscription to Translator Text API.|
154+
|Ocp-Apim-Subscription-Region| The value is the region of the translator resource. This value is optional if the resource is `global`|
99155

100-
If you use a bearer token, you must obtain the token from the region endpoint: `https://<your-region>.api.cognitive.microsoft.com/sts/v1.0/issueToken`.
156+
Here's an example request to call the Translator API using the custom endpoint
101157

158+
```curl
159+
// Pass secret key and region using headers
160+
curl -X POST "https://<your-custom-domain>.cognitiveservices.azure.com/translator/text/v3.0/translate?api-version=3.0&to=es" \
161+
-H "Ocp-Apim-Subscription-Key:<your-key>" \
162+
-H "Ocp-Apim-Subscription-Region:<your-region>" \
163+
-H "Content-Type: application/json" \
164+
-d "[{'Text':'Hello, what is your name?'}]"
165+
```
102166

103167
## Errors
104168

0 commit comments

Comments
 (0)