Skip to content

Commit a8c8c05

Browse files
authored
Merge pull request #126979 from v-jaswel/patch-14
Update quickstart code include links
2 parents 719e073 + fd0b8bd commit a8c8c05

14 files changed

+98
-126
lines changed

articles/cognitive-services/QnAMaker/Quickstarts/create-new-kb-csharp.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Build succeeded.
5555

5656
At the top of Program.cs, replace the single using statement with the following lines to add necessary dependencies to the project:
5757

58-
[!code-csharp[Add the required dependencies](~/samples-qnamaker-csharp/documentation-samples/quickstarts/create-knowledge-base/QnaQuickstartCreateKnowledgebase/Program.cs?range=1-11 "Add the required dependencies")]
58+
:::code language="csharp" source="~/cognitive-services-quickstart-code/dotnet/QnAMaker/rest/create-kb.cs" id="dependencies":::
5959

6060
## Add the required constants
6161

@@ -66,26 +66,26 @@ Set the following values in environment variables:
6666
* `QNA_MAKER_SUBSCRIPTION_KEY` - The **key** is a 32 character string and is available in the Azure portal, on the QnA Maker resource, on the Quickstart page. This is not the same as the prediction endpoint key.
6767
* `QNA_MAKER_ENDPOINT` - The **endpoint** is the URL for authoring, in the format of `https://YOUR-RESOURCE-NAME.cognitiveservices.azure.com`. This is not the same URL used to query the prediction endpoint.
6868

69-
[!code-csharp[Add the required constants](~/samples-qnamaker-csharp/documentation-samples/quickstarts/create-knowledge-base/QnaQuickstartCreateKnowledgebase/Program.cs?range=17-26 "Add the required constants")]
69+
:::code language="csharp" source="~/cognitive-services-quickstart-code/dotnet/QnAMaker/rest/create-kb.cs" id="constants":::
7070

7171
## Add the KB definition
7272

7373
After the constants, add the following KB definition:
7474

75-
[!code-csharp[Add the required constants](~/samples-qnamaker-csharp/documentation-samples/quickstarts/create-knowledge-base/QnaQuickstartCreateKnowledgebase/Program.cs?range=28-58 "Add the knowledge base definition")]
75+
:::code language="csharp" source="~/cognitive-services-quickstart-code/dotnet/QnAMaker/rest/create-kb.cs" id="kb":::
7676

7777
## Add supporting functions and structures
7878
Add the following code block inside the Program class:
7979

80-
[!code-csharp[Add supporting functions and structures](~/samples-qnamaker-csharp/documentation-samples/quickstarts/create-knowledge-base/QnaQuickstartCreateKnowledgebase/Program.cs?range=60-99 "Add supporting functions and structures")]
80+
:::code language="csharp" source="~/cognitive-services-quickstart-code/dotnet/QnAMaker/rest/create-kb.cs" id="support":::
8181

8282
## Add a POST request to create KB
8383

8484
The following code makes an HTTPS request to the QnA Maker API to create a KB and receives the response:
8585

86-
[!code-csharp[Add PostCreateKB to request via POST](~/samples-qnamaker-csharp/documentation-samples/quickstarts/create-knowledge-base/QnaQuickstartCreateKnowledgebase/Program.cs?range=145-165 "Add PostCreateKB to request via POST")]
86+
:::code language="csharp" source="~/cognitive-services-quickstart-code/dotnet/QnAMaker/rest/create-kb.cs" id="post":::
8787

88-
[!code-csharp[Add a POST request to create KB](~/samples-qnamaker-csharp/documentation-samples/quickstarts/create-knowledge-base/QnaQuickstartCreateKnowledgebase/Program.cs?range=101-122 "Add a POST request to create KB")]
88+
:::code language="csharp" source="~/cognitive-services-quickstart-code/dotnet/QnAMaker/rest/create-kb.cs" id="post_create_kb":::
8989

9090
This API call returns a JSON response that includes the operation ID. Use the operation ID to determine if the KB is successfully created.
9191

@@ -103,9 +103,9 @@ This API call returns a JSON response that includes the operation ID. Use the op
103103

104104
Check the status of the operation.
105105

106-
[!code-csharp[Add GetStatus to request via GET](~/samples-qnamaker-csharp/documentation-samples/quickstarts/create-knowledge-base/QnaQuickstartCreateKnowledgebase/Program.cs?range=167-187 "Add GetStatus to request via GET")]
106+
:::code language="csharp" source="~/cognitive-services-quickstart-code/dotnet/QnAMaker/rest/create-kb.cs" id="get":::
107107

108-
[!code-csharp[Add GET request to determine creation status](~/samples-qnamaker-csharp/documentation-samples/quickstarts/create-knowledge-base/QnaQuickstartCreateKnowledgebase/Program.cs?range=124-143 "Add GET request to determine creation status")]
108+
:::code language="csharp" source="~/cognitive-services-quickstart-code/dotnet/QnAMaker/rest/create-kb.cs" id="get_status":::
109109

110110
This API call returns a JSON response that includes the operation status:
111111

@@ -136,13 +136,13 @@ Repeat the call until success or failure:
136136

137137
The following method creates the KB and repeats checks on the status. The _create_ **Operation ID** is returned in the POST response header field **Location**, then used as part of the route in the GET request. Because the KB creation may take some time, you need to repeat calls to check the status until the status is either successful or fails. When the operation succeeds, the KB ID is returned in **resourceLocation**.
138138

139-
[!code-csharp[Add CreateKB method](~/samples-qnamaker-csharp/documentation-samples/quickstarts/create-knowledge-base/QnaQuickstartCreateKnowledgebase/Program.cs?range=189-254 "Add CreateKB method")]
139+
:::code language="csharp" source="~/cognitive-services-quickstart-code/dotnet/QnAMaker/rest/create-kb.cs" id="create_kb":::
140140

141141
## Add the CreateKB method to Main
142142

143143
Change the Main method to call the CreateKB method:
144144

145-
[!code-csharp[Add CreateKB method](~/samples-qnamaker-csharp/documentation-samples/quickstarts/create-knowledge-base/QnaQuickstartCreateKnowledgebase/Program.cs?range=256-265 "Add CreateKB method")]
145+
:::code language="csharp" source="~/cognitive-services-quickstart-code/dotnet/QnAMaker/rest/create-kb.cs" id="main":::
146146

147147
## Build and run the program
148148

articles/cognitive-services/QnAMaker/Quickstarts/create-new-kb-go.md

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,44 +32,34 @@ Create a file named `create-new-knowledge-base.go`.
3232

3333
At the top of `create-new-knowledge-base.go`, add the following lines to add necessary dependencies to the project:
3434

35-
[!code-go[Add the required dependencies](~/samples-qnamaker-go/documentation-samples/quickstarts/create-knowledge-base/create-new-knowledge-base.go?range=1-11 "Add the required dependencies")]
36-
37-
## Add the required constants
38-
After the preceding required dependencies, add the required constants to access QnA Maker.
39-
40-
Set the following values:
41-
42-
* `<your-qna-maker-subscription-key>` - The **key** is a 32 character string and is available in the Azure portal, on the QnA Maker resource, on the Quickstart page. This is not the same as the prediction endpoint key.
43-
* `{your-resource-name}` - Your **resource name** is used to construct the authoring endpoint URL for authoring, in the format of `https://YOUR-RESOURCE-NAME.cognitiveservices.azure.com`. This is not the same URL used to query the prediction endpoint.
44-
45-
[!code-go[Add the required constants](~/samples-qnamaker-go/documentation-samples/quickstarts/create-knowledge-base/create-new-knowledge-base.go?range=13-20 "Add the required constants")]
35+
:::code language="go" source="~/cognitive-services-quickstart-code/go/QnAMaker/rest/create-kb.go" id="dependencies":::
4636

4737
## Add the KB model definition
4838
After the constants, add the following KB model definition. The model is converting into a string after the definition.
4939

50-
[!code-go[Add the KB model definition](~/samples-qnamaker-go/documentation-samples/quickstarts/create-knowledge-base/create-new-knowledge-base.go?range=22-44 "Add the KB model definition")]
40+
:::code language="go" source="~/cognitive-services-quickstart-code/go/QnAMaker/rest/create-kb.go" id="model":::
5141

5242
## Add supporting structures and functions
5343

5444
Next, add the following supporting functions.
5545

56-
1. Add the structure for an HTTP request:
46+
1. Add the structure for an HTTP response:
5747

58-
[!code-go[Add the structure for an HTTP request](~/samples-qnamaker-go/documentation-samples/quickstarts/create-knowledge-base/create-new-knowledge-base.go?range=46-49 "Add the structure for an HTTP request")]
48+
:::code language="go" source="~/cognitive-services-quickstart-code/go/QnAMaker/rest/create-kb.go" id="response":::
5949

60-
2. Add the following method to handle a POST to the QnA Maker APIs. For this quickstart, the POST is used to send the KB definition to QnA Maker.
50+
1. Add the following method to handle a POST to the QnA Maker APIs. For this quickstart, the POST is used to send the KB definition to QnA Maker.
6151

62-
[!code-go[Add the POST method](~/samples-qnamaker-go/documentation-samples/quickstarts/create-knowledge-base/create-new-knowledge-base.go?range=51-66 "Add the POST method")]
52+
:::code language="go" source="~/cognitive-services-quickstart-code/go/QnAMaker/rest/create-kb.go" id="post":::
6353

64-
3. Add the following method to handle a GET to the QnA Maker APIs. For this quickstart, the GET is used to check the status of the creation operation.
54+
1. Add the following method to handle a GET to the QnA Maker APIs. For this quickstart, the GET is used to check the status of the creation operation.
6555

66-
[!code-go[Add the GET method](~/samples-qnamaker-go/documentation-samples/quickstarts/create-knowledge-base/create-new-knowledge-base.go?range=68-83 "Add the GET method")]
56+
:::code language="go" source="~/cognitive-services-quickstart-code/go/QnAMaker/rest/create-kb.go" id="get":::
6757

6858
## Add function to create KB
6959

7060
Add the following functions to make an HTTP POST request to create the knowledge base. The _create_ **Operation ID** is returned in the POST response header field **Location**, then used as part of the route in the GET request. The `Ocp-Apim-Subscription-Key` is the QnA Maker service key, used for authentication.
7161

72-
[!code-go[Add the create_kb method](~/samples-qnamaker-go/documentation-samples/quickstarts/create-knowledge-base/create-new-knowledge-base.go?range=85-97 "Add the create_kb method")]
62+
:::code language="go" source="~/cognitive-services-quickstart-code/go/QnAMaker/rest/create-kb.go" id="create_kb":::
7363

7464
This API call returns a JSON response that includes the operation ID. Use the operation ID to determine if the KB is successfully created.
7565

@@ -87,7 +77,7 @@ This API call returns a JSON response that includes the operation ID. Use the op
8777

8878
Add the following function to make an HTTP GET request to check the operation status. The `Ocp-Apim-Subscription-Key` is the QnA Maker service key, used for authentication.
8979

90-
[!code-go[Add the check_status method](~/samples-qnamaker-go/documentation-samples/quickstarts/create-knowledge-base/create-new-knowledge-base.go?range=99-108 "Add the check_status method")]
80+
:::code language="go" source="~/cognitive-services-quickstart-code/go/QnAMaker/rest/create-kb.go" id="get_status":::
9181

9282
Repeat the call until success or failure:
9383

@@ -105,7 +95,7 @@ Repeat the call until success or failure:
10595

10696
The following function is the main function and creates the KB and repeats checks on the status. Because the KB creation may take some time, you need to repeat calls to check the status until the status is either successful or fails.
10797

108-
[!code-go[Add the main method](~/samples-qnamaker-go/documentation-samples/quickstarts/create-knowledge-base/create-new-knowledge-base.go?range=110-140 "Add the main method")]
98+
:::code language="go" source="~/cognitive-services-quickstart-code/go/QnAMaker/rest/create-kb.go" id="main":::
10999

110100

111101
## Compile the program
@@ -130,4 +120,4 @@ Once your knowledge base is created, you can view it in your QnA Maker Portal, [
130120
## Next steps
131121

132122
> [!div class="nextstepaction"]
133-
> [QnA Maker (V4) REST API Reference](https://go.microsoft.com/fwlink/?linkid=2092179)
123+
> [QnA Maker (V4) REST API Reference](https://go.microsoft.com/fwlink/?linkid=2092179)

articles/cognitive-services/QnAMaker/Quickstarts/create-new-kb-java.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Quickstart: Create knowledge base - REST, Java - QnA Maker"
3-
description: This Java REST-based quickstart walks you through creating a sample QnA Maker knowledge base, programmatically, that will appear in your Azure Dashboard of your Cognitive Services API account..
3+
description: This Java REST-based quickstart walks you through creating a sample QnA Maker knowledge base, programmatically, that will appear in your Azure Dashboard of your Cognitive Services API account.
44
ms.date: 12/16/2019
55
ROBOTS: NOINDEX,NOFOLLOW
66
ms.custom: RESTCURL2020FEB27, devx-track-java
@@ -34,7 +34,7 @@ Create a file named `CreateKB.java`
3434

3535
At the top of `CreateKB.java`, add the following lines to add necessary dependencies to the project:
3636

37-
[!code-java[Add the required dependencies](~/samples-qnamaker-java/documentation-samples/quickstarts/create-knowledge-base/CreateKB.java?range=1-5 "Add the required dependencies")]
37+
:::code language="java" source="~/cognitive-services-quickstart-code/java/QnAMaker/rest/CreateKB.java" id="dependencies":::
3838

3939
## Add the required constants
4040
After the preceding required dependencies, add the required constants to the `CreateKB` class to access QnA Maker.
@@ -43,43 +43,43 @@ You must have a [QnA Maker service](../How-To/set-up-qnamaker-service-azure.md).
4343

4444
Set the following values:
4545

46-
* `<your-qna-maker-subscription-key>` - The **key** is a 32 character string and is available in the Azure portal, on the QnA Maker resource, on the Quickstart page. This is not the same as the prediction endpoint key.
47-
* `<your-resource-name>` - Your **resource name** is used to construct the authoring endpoint URL for authoring, in the format of `https://YOUR-RESOURCE-NAME.cognitiveservices.azure.com`. This is not the same URL used to query the prediction endpoint.
46+
* `<your-qna-maker-subscription-key>` - The **key** is a 32 character string and is available in the Azure portal, on the QnA Maker resource, on the Quickstart page. This key is not the same as the prediction endpoint key.
47+
* `<your-resource-name>` - Your **resource name** is used to construct the authoring endpoint URL for authoring, in the format of `https://YOUR-RESOURCE-NAME.cognitiveservices.azure.com`. This resource name is not the same as the one used to query the prediction endpoint.
4848

4949
You do not need to add the final curly bracket to end the class; it is in the final code snippet at the end of this quickstart.
5050

51-
[!code-java[Add the required constants](~/samples-qnamaker-java/documentation-samples/quickstarts/create-knowledge-base/CreateKB.java?range=26-34 "Add the required constants")]
51+
:::code language="java" source="~/cognitive-services-quickstart-code/java/QnAMaker/rest/CreateKB.java" id="constants":::
5252

5353

5454
## Add the KB model definition classes
5555
After the constants, add the following classes and functions inside the `CreateKB` class to serialize the model definition object into JSON.
5656

57-
[!code-java[Add the KB model definition classes](~/samples-qnamaker-java/documentation-samples/quickstarts/create-knowledge-base/CreateKB.java?range=36-80 "Add the KB model definition classes")]
57+
:::code language="java" source="~/cognitive-services-quickstart-code/java/QnAMaker/rest/CreateKB.java" id="model":::
5858

5959
## Add supporting functions
6060

6161
Next, add the following supporting functions inside the `CreateKB` class.
6262

6363
1. Add the following function to print out JSON in a readable format:
6464

65-
[!code-java[Add the PrettyPrint function](~/samples-qnamaker-java/documentation-samples/quickstarts/create-knowledge-base/CreateKB.java?range=82-87 "Add the KB model definition classes")]
65+
:::code language="java" source="~/cognitive-services-quickstart-code/java/QnAMaker/rest/CreateKB.java" id="pretty":::
6666

6767
2. Add the following class to manage the HTTP response:
6868

69-
[!code-java[Add class to manage the HTTP response](~/samples-qnamaker-java/documentation-samples/quickstarts/create-knowledge-base/CreateKB.java?range=89-97 "Add class to manage the HTTP response")]
69+
:::code language="java" source="~/cognitive-services-quickstart-code/java/QnAMaker/rest/CreateKB.java" id="response":::
7070

7171
3. Add the following method to make a POST request to the QnA Maker APIs. The `Ocp-Apim-Subscription-Key` is the QnA Maker service key, used for authentication.
7272

73-
[!code-java[Add POST method](~/samples-qnamaker-java/documentation-samples/quickstarts/create-knowledge-base/CreateKB.java?range=99-121 "Add POST method")]
73+
:::code language="java" source="~/cognitive-services-quickstart-code/java/QnAMaker/rest/CreateKB.java" id="post":::
7474

7575
4. Add the following method to make a GET request to the QnA Maker APIs.
7676

77-
[!code-java[Add GET method](~/samples-qnamaker-java/documentation-samples/quickstarts/create-knowledge-base/CreateKB.java?range=123-137 "Add GET method")]
77+
:::code language="java" source="~/cognitive-services-quickstart-code/java/QnAMaker/rest/CreateKB.java" id="get":::
7878

7979
## Add a method to create the KB
8080
Add the following method to create the KB by calling into the Post method.
8181

82-
[!code-java[Add CreateKB method](~/samples-qnamaker-java/documentation-samples/quickstarts/create-knowledge-base/CreateKB.java?range=139-144 "Add CreateKB method")]
82+
:::code language="java" source="~/cognitive-services-quickstart-code/java/QnAMaker/rest/CreateKB.java" id="create_kb":::
8383

8484
This API call returns a JSON response that includes the operation ID. Use the operation ID to determine if the KB is successfully created.
8585

@@ -96,7 +96,7 @@ This API call returns a JSON response that includes the operation ID. Use the op
9696
## Add a method to get status
9797
Add the following method to check the creation status.
9898

99-
[!code-java[Add GetStatus method](~/samples-qnamaker-java/documentation-samples/quickstarts/create-knowledge-base/CreateKB.java?range=146-150 "Add GetStatus method")]
99+
:::code language="java" source="~/cognitive-services-quickstart-code/java/QnAMaker/rest/CreateKB.java" id="get_status":::
100100

101101
Repeat the call until success or failure:
102102

@@ -114,17 +114,17 @@ Repeat the call until success or failure:
114114
## Add a main method
115115
The main method creates the KB, then polls for the status. The operation ID is returned in the POST response header field **Location**, then used as part of the route in the GET request. The `while` loop retries the status if it is not completed.
116116

117-
[!code-java[Add main method](~/samples-qnamaker-java/documentation-samples/quickstarts/create-knowledge-base/CreateKB.java?range=152-191 "Add main method")]
117+
:::code language="java" source="~/cognitive-services-quickstart-code/java/QnAMaker/rest/CreateKB.java" id="main":::
118118

119119
## Compile and run the program
120120

121-
1. Make sure the gson library is in the `./libs` directory. At the command-line, compile the file `CreateKB.java`:
121+
1. Make sure the gson library is in the `./libs` directory. At the command line, compile the file `CreateKB.java`:
122122

123123
```bash
124124
javac -cp ".;libs/*" CreateKB.java
125125
```
126126

127-
2. Enter the following command at a command-line to run the program. It will send the request to the QnA Maker API to create the KB, then it will poll for the results every 30 seconds. Each response is printed to the console window.
127+
2. Enter the following command at a command line to run the program. It will send the request to the QnA Maker API to create the KB, then it will poll for the results every 30 seconds. Each response is printed to the console window.
128128

129129
```bash
130130
java -cp ",;libs/*" CreateKB
@@ -137,4 +137,4 @@ Once your knowledge base is created, you can view it in your QnA Maker Portal, [
137137
## Next steps
138138

139139
> [!div class="nextstepaction"]
140-
> [QnA Maker (V4) REST API Reference](https://go.microsoft.com/fwlink/?linkid=2092179)
140+
> [QnA Maker (V4) REST API Reference](https://go.microsoft.com/fwlink/?linkid=2092179)

0 commit comments

Comments
 (0)