Skip to content

Commit 1df563d

Browse files
author
Jill Grant
authored
Merge pull request #235553 from jboback/EnvVariablesSummarization
Summarization Environment Variables
2 parents 5e30740 + 06a74d9 commit 1df563d

File tree

5 files changed

+65
-40
lines changed

5 files changed

+65
-40
lines changed

articles/cognitive-services/language-service/summarization/includes/quickstarts/csharp-sdk.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ Use this quickstart to create a text summarization application with the client l
3737
3838
## Setting up
3939

40+
[!INCLUDE [Create environment variables](../../../includes/environment-variables.md)]
41+
42+
> [!div class="nextstepaction"]
43+
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=CSHARP&Pillar=Language&Product=Summarization&Page=quickstart&Section=Create-environment-variables" target="_target">I ran into an issue</a>
44+
4045
### Create a new .NET Core application
4146

4247
Using the Visual Studio IDE, create a new .NET Core console app. This will create a "Hello World" project with a single C# source file: *program.cs*.
@@ -56,7 +61,7 @@ Install the client library by right-clicking on the solution in the **Solution E
5661
5762
## Code example
5863

59-
Copy the following code into your *program.cs* file. Remember to replace the `key` variable with the key for your resource, and replace the `endpoint` variable with the endpoint for your resource. Then run the code.
64+
Copy the following code into your *program.cs* file. Then run the code.
6065

6166
[!INCLUDE [find the key and endpoint for a resource](../../../includes/find-azure-resource-info.md)]
6267

@@ -73,8 +78,12 @@ namespace Example
7378
{
7479
class Program
7580
{
76-
private static readonly AzureKeyCredential credentials = new AzureKeyCredential("replace-with-your-key-here");
77-
private static readonly Uri endpoint = new Uri("replace-with-your-endpoint-here");
81+
// This example requires environment variables named "LANGUAGE_KEY" and "LANGUAGE_ENDPOINT"
82+
static string languageKey = Environment.GetEnvironmentVariable("LANGUAGE_KEY");
83+
static string languageEndpoint = Environment.GetEnvironmentVariable("LANGUAGE_ENDPOINT");
84+
85+
private static readonly AzureKeyCredential credentials = new AzureKeyCredential(languageKey);
86+
private static readonly Uri endpoint = new Uri(languageEndpoint);
7887

7988
// Example method for summarizing text
8089
static async Task TextSummarizationExample(TextAnalyticsClient client)

articles/cognitive-services/language-service/summarization/includes/quickstarts/java-sdk.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@ Create a Maven project in your preferred IDE or development environment. Then ad
4646
> [!div class="nextstepaction"]
4747
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=CSHARP&Pillar=Language&Product=Summarization&Page=quickstart&Section=Set-up-the-environment" target="_target">I ran into an issue</a>
4848
49+
[!INCLUDE [Create environment variables](../../../includes/environment-variables.md)]
50+
51+
> [!div class="nextstepaction"]
52+
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=JAVA&Pillar=Language&Product=Summarization&Page=quickstart&Section=Create-environment-variables" target="_target">I ran into an issue</a>
53+
4954
## Code example
5055

51-
Create a Java file named `Example.java`. Open the file and copy the below code. Remember to replace the `key` variable with the key for your resource, and replace the `endpoint` variable with the endpoint for your resource. Then run the code.
56+
Create a Java file named `Example.java`. Open the file and copy the below code. Then run the code.
5257

5358
[!INCLUDE [find the key and endpoint for a resource](../../../includes/find-azure-resource-info.md)]
5459

@@ -64,11 +69,12 @@ import com.azure.ai.textanalytics.util.*;
6469

6570
public class Example {
6671

67-
private static String KEY = "replace-with-your-key-here";
68-
private static String ENDPOINT = "replace-with-your-endpoint-here";
72+
// This example requires environment variables named "LANGUAGE_KEY" and "LANGUAGE_ENDPOINT"
73+
private static String languageKey = System.getenv("LANGUAGE_KEY");
74+
private static String languageEndpoint = System.getenv("LANGUAGE_ENDPOINT");
6975

7076
public static void main(String[] args) {
71-
TextAnalyticsClient client = authenticateClient(KEY, ENDPOINT);
77+
TextAnalyticsClient client = authenticateClient(languageKey, languageEndpoint);
7278
summarizationExample(client);
7379
}
7480
// Method to authenticate the client object with your key and endpoint

articles/cognitive-services/language-service/summarization/includes/quickstarts/nodejs-sdk.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ Use this quickstart to create a text summarization application with the client l
2929
3030
## Setting up
3131

32+
[!INCLUDE [Create environment variables](../../../includes/environment-variables.md)]
33+
34+
> [!div class="nextstepaction"]
35+
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=JAVASCRIPT&Pillar=Language&Product=Summarization&Page=quickstart&Section=Create-environment-variables" target="_target">I ran into an issue</a>
36+
3237
### Create a new Node.js application
3338

3439
In a console window (such as cmd, PowerShell, or Bash), create a new directory for your app, and navigate to it.
@@ -58,7 +63,7 @@ npm install --save @azure/[email protected]
5863
5964
## Code example
6065

61-
Open the file and copy the below code. Remember to replace the `key` variable with the key for your resource, and replace the `endpoint` variable with the endpoint for your resource. Then run the code.
66+
Open the file and copy the below code. Then run the code.
6267

6368
[!INCLUDE [find the key and endpoint for a resource](../../../includes/find-azure-resource-info.md)]
6469

@@ -75,9 +80,9 @@ const { AzureKeyCredential, TextAnalysisClient } = require("@azure/ai-language-t
7580
// Load the .env file if it exists
7681
require("dotenv").config();
7782

78-
// You'll need to set these environment variables or edit the following values
79-
const endpoint = process.env["ENDPOINT"] || "<paste-your-endpoint-here>";
80-
const apiKey = process.env["LANGUAGE_API_KEY"] || "<paste-your-key-here>";
83+
// This example requires environment variables named "LANGUAGE_KEY" and "LANGUAGE_ENDPOINT"
84+
const endpoint = process.env.LANGUAGE_ENDPOINT;
85+
const apiKey = process.env.LANGUAGE_KEY;
8186

8287
const documents = [
8388
`

articles/cognitive-services/language-service/summarization/includes/quickstarts/python-sdk.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ Use this quickstart to create a text summarization application with the client l
3333

3434
> [!div class="nextstepaction"]
3535
> <a href="> [!div class="nextstepaction"]
36-
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=JAVASCRIPT&Pillar=Language&Product=Summarization&Page=quickstart&Section=Code-example" target="_target">I ran into an issue</a>" target="_target">I ran into an issue</a>
36+
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=PYTHON&Pillar=Language&Product=Summarization&Page=quickstart&Section=Code-example" target="_target">I ran into an issue</a>" target="_target">I ran into an issue</a>
3737
3838
## Setting up
3939

40+
[!INCLUDE [Create environment variables](../../../includes/environment-variables.md)]
41+
42+
> [!div class="nextstepaction"]
43+
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=PYTHON&Pillar=Language&Product=Summarization&Page=quickstart&Section=Create-environment-variables" target="_target">I ran into an issue</a>
44+
4045
### Install the client library
4146

4247
After installing Python, you can install the client library with:
@@ -61,15 +66,16 @@ pip install azure-ai-language-conversations==1.1.0b3
6166

6267
## Code example
6368

64-
Create a new Python file and copy the below code. Remember to replace the `key` variable with the key for your resource, and replace the `endpoint` variable with the endpoint for your resource. Then run the code.
69+
Create a new Python file and copy the below code. Then run the code.
6570

6671
[!INCLUDE [find the key and endpoint for a resource](../../../includes/find-azure-resource-info.md)]
6772

6873
# [Document summarization](#tab/document-summarization)
6974

7075
```python
71-
key = "paste-your-key-here"
72-
endpoint = "paste-your-endpoint-here"
76+
# This example requires environment variables named "LANGUAGE_KEY" and "LANGUAGE_ENDPOINT"
77+
key = os.environ.get('LANGUAGE_KEY')
78+
endpoint = os.environ.get('LANGUAGE_ENDPOINT')
7379

7480
from azure.ai.textanalytics import TextAnalyticsClient
7581
from azure.core.credentials import AzureKeyCredential

articles/cognitive-services/language-service/summarization/includes/quickstarts/rest-api.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@ Use this quickstart to send text summarization requests using the REST API. In t
3434
> [!div class="nextstepaction"]
3535
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=REST API&Pillar=Language&Product=Summarization&Page=quickstart&Section=Prerequisites" target="_target">I ran into an issue</a>
3636
37+
## Setting up
38+
39+
[!INCLUDE [Create environment variables](../../../includes/environment-variables.md)]
40+
41+
> [!div class="nextstepaction"]
42+
> <a href="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=REST API&Pillar=Language&Product=Summarization&Page=quickstart&Section=Create-environment-variables" target="_target">I ran into an issue</a>
43+
3744
## Example request
3845

3946
> [!NOTE]
4047
> * The following BASH examples use the `\` line continuation character. If your console or terminal uses a different line continuation character, use that character.
4148
> * You can find language specific samples on [GitHub](https://github.com/Azure-Samples/cognitive-services-quickstart-code).
42-
> * Go to the Azure portal and find the key and endpoint for the Language resource you created in the prerequisites. They will be located on the resource's **key and endpoint** page, under **resource management**. Then replace the strings in the code below with your key and endpoint.
4349
To call the API, you need the following information:
4450

4551
Choose the type of summarization you would like to perform, and select one of the tabs below to see an example API call:
@@ -60,7 +66,7 @@ Choose the type of summarization you would like to perform, and select one of th
6066
|`-H "Ocp-Apim-Subscription-Key:<key>` | Specifies the key for accessing the API. |
6167
|`-d <documents>` | The JSON containing the documents you want to send. |
6268

63-
The following cURL commands are executed from a BASH shell. Edit these commands with your own resource name, resource key, and JSON values.
69+
The following cURL commands are executed from a BASH shell. Edit these commands with your own JSON values.
6470

6571
## Document summarization
6672

@@ -71,9 +77,9 @@ The following example will get you started with document extractive summarizatio
7177
1. Copy the command below into a text editor. The BASH example uses the `\` line continuation character. If your console or terminal uses a different line continuation character, use that character instead.
7278

7379
```bash
74-
curl -i -X POST https://<your-language-resource-endpoint>/language/analyze-text/jobs?api-version=2022-10-01-preview \
80+
curl -i -X POST $LANGUAGE_ENDPOINT/language/analyze-text/jobs?api-version=2022-10-01-preview \
7581
-H "Content-Type: application/json" \
76-
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>" \
82+
-H "Ocp-Apim-Subscription-Key: $LANGUAGE_KEY" \
7783
-d \
7884
'
7985
{
@@ -99,26 +105,23 @@ curl -i -X POST https://<your-language-resource-endpoint>/language/analyze-text/
99105
}
100106
'
101107
```
102-
2. Make the following changes in the command where needed:
103-
- Replace the value `your-language-resource-key` with your key.
104-
- Replace the first part of the request URL `your-language-resource-endpoint` with your endpoint URL.
105108

106-
3. Open a command prompt window (for example: BASH).
109+
2. Open a command prompt window (for example: BASH).
107110

108-
4. Paste the command from the text editor into the command prompt window, then run the command.
111+
3. Paste the command from the text editor into the command prompt window, then run the command.
109112

110-
5. Get the `operation-location` from the response header. The value will look similar to the following URL:
113+
4. Get the `operation-location` from the response header. The value will look similar to the following URL:
111114

112115
```http
113116
https://<your-language-resource-endpoint>/language/analyze-text/jobs/12345678-1234-1234-1234-12345678?api-version=2022-10-01-preview
114117
```
115118

116-
6. To get the results of the request, use the following cURL command. Be sure to replace `<my-job-id>` with the numerical ID value you received from the previous `operation-location` response header:
119+
5. To get the results of the request, use the following cURL command. Be sure to replace `<my-job-id>` with the numerical ID value you received from the previous `operation-location` response header:
117120

118121
```bash
119-
curl -X GET https://<your-language-resource-endpoint>/language/analyze-text/jobs/<my-job-id>?api-version=2022-10-01-preview \
122+
curl -X GET $LANGUAGE_ENDPOINT/language/analyze-text/jobs/<my-job-id>?api-version=2022-10-01-preview \
120123
-H "Content-Type: application/json" \
121-
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>"
124+
-H "Ocp-Apim-Subscription-Key: $LANGUAGE_KEY"
122125
```
123126

124127
> [!div class="nextstepaction"]
@@ -209,9 +212,9 @@ The following example will get you started with conversation issue and resolutio
209212
1. Copy the command below into a text editor. The BASH example uses the `\` line continuation character. If your console or terminal uses a different line continuation character, use that character instead.
210213

211214
```bash
212-
curl -i -X POST https://<your-language-resource-endpoint>/language/analyze-conversations/jobs?api-version=2022-10-01-preview \
215+
curl -i -X POST $LANGUAGE_ENDPOINT/language/analyze-conversations/jobs?api-version=2022-10-01-preview \
213216
-H "Content-Type: application/json" \
214-
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>" \
217+
-H "Ocp-Apim-Subscription-Key: $LANGUAGE_KEY" \
215218
-d \
216219
'
217220
{
@@ -291,26 +294,22 @@ curl -i -X POST https://<your-language-resource-endpoint>/language/analyze-conve
291294
```
292295
Only the `resolution` aspect supports sentenceCount. If you do not specify the `sentenceCount` parameter, the model will determine the summary's length. Note that `sentenceCount` is just the approximation of sentence count of output summary, range 1 to 7.
293296

294-
2. Make the following changes in the command where needed:
295-
- Replace the value `your-language-resource-key` with your key.
296-
- Replace the first part of the request URL `your-language-resource-endpoint` with your endpoint URL.
297-
298-
3. Open a command prompt window (for example: BASH).
297+
2. Open a command prompt window (for example: BASH).
299298

300-
4. Paste the command from the text editor into the command prompt window, then run the command.
299+
3. Paste the command from the text editor into the command prompt window, then run the command.
301300

302-
5. Get the `operation-location` from the response header. The value will look similar to the following URL:
301+
4. Get the `operation-location` from the response header. The value will look similar to the following URL:
303302

304303
```http
305304
https://<your-language-resource-endpoint>/language/analyze-conversations/jobs/12345678-1234-1234-1234-12345678?api-version=2022-10-01-preview
306305
```
307306

308-
6. To get the results of the request, use the following cURL command. Be sure to replace `<my-job-id>` with the numerical ID value you received from the previous `operation-location` response header:
307+
5. To get the results of the request, use the following cURL command. Be sure to replace `<my-job-id>` with the numerical ID value you received from the previous `operation-location` response header:
309308

310309
```bash
311-
curl -X GET https://<your-language-resource-endpoint>/language/analyze-conversations/jobs/<my-job-id>?api-version=2022-10-01-preview \
310+
curl -X GET $LANGUAGE_ENDPOINT/language/analyze-conversations/jobs/<my-job-id>?api-version=2022-10-01-preview \
312311
-H "Content-Type: application/json" \
313-
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>"
312+
-H "Ocp-Apim-Subscription-Key: $LANGUAGE_KEY"
314313
```
315314

316315
> [!div class="nextstepaction"]

0 commit comments

Comments
 (0)