Skip to content

Commit 19bc638

Browse files
authored
Merge pull request #113991 from dksimpson/DKS-US1712683-bing-autosuggest
[CogSvcs] Refresh Bing Autosuggest API quickstarts
2 parents 003972b + cbaa827 commit 19bc638

File tree

9 files changed

+96
-106
lines changed

9 files changed

+96
-106
lines changed

articles/cognitive-services/Bing-Autosuggest/includes/quickstarts/autosuggest-client-library-csharp.md

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: aahill
66
manager: nitinme
77
ms.service: cognitive-services
88
ms.topic: include
9-
ms.date: 04/06/2020
9+
ms.date: 05/06/2020
1010
ms.author: aahi
1111
---
1212

@@ -18,29 +18,24 @@ Use the Bing Autosuggest client library for .NET to get search suggestions based
1818

1919
## Prerequisites
2020

21-
* Azure subscription - [Create one for free](https://azure.microsoft.com/free/)
21+
* An Azure subscription. If you don't already have an Azure subscription, [you can create one for free](https://azure.microsoft.com/free/).
2222
* The current version of [.NET Core](https://dotnet.microsoft.com/download/dotnet-core).
2323

24-
## Setting up
25-
26-
### Create an Azure resource
27-
2824
[!INCLUDE [cognitive-services-bing-autosuggest-signup-requirements](~/includes/cognitive-services-bing-autosuggest-signup-requirements.md)]
2925

30-
### Create an environment variable
26+
## Create environment variables
3127

3228
>[!NOTE]
3329
> The endpoints for non-trial resources created after July 1, 2019 use the custom subdomain format shown below. For more information and a complete list of regional endpoints, see [Custom subdomain names for Cognitive Services](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-custom-subdomains).
3430
3531
Using your key and endpoint from the resource you created, create two environment variables for authentication:
3632
<!-- replace the below variable names with the names expected in the code sample.-->
37-
* `AUTOSUGGEST_SUBSCRIPTION_KEY` - The resource key for authenticating your requests.
38-
* `AUTOSUGGEST_ENDPOINT` - The resource endpoint for sending API requests. It will look like this:
39-
* `https://<your-custom-subdomain>.api.cognitive.microsoft.com`
33+
* `AUTOSUGGEST_SUBSCRIPTION_KEY`: The resource key for authenticating your requests.
34+
* `AUTOSUGGEST_ENDPOINT`: The resource endpoint for sending API requests. It should look like this: `https://<your-custom-subdomain>.api.cognitive.microsoft.com`.
4035

4136
Use the instructions for your operating system.
4237
<!-- replace the below endpoint and key examples -->
43-
#### [Windows](#tab/windows)
38+
### [Windows](#tab/windows)
4439

4540
```console
4641
setx AUTOSUGGEST_SUBSCRIPTION_KEY <replace-with-your-autosuggest-api-key>
@@ -49,7 +44,7 @@ setx AUTOSUGGEST_ENDPOINT <replace-with-your-autosuggest-api-endpoint>
4944

5045
After you add the environment variable, restart the console window.
5146

52-
#### [Linux](#tab/linux)
47+
### [Linux](#tab/linux)
5348

5449
```bash
5550
export AUTOSUGGEST_SUBSCRIPTION_KEY=<replace-with-your-autosuggest-api-key>
@@ -58,7 +53,7 @@ export AUTOSUGGEST_ENDPOINT=<replace-with-your-autosuggest-api-endpoint>
5853

5954
After you add the environment variable, run `source ~/.bashrc` from your console window to make the changes effective.
6055

61-
#### [macOS](#tab/unix)
56+
### [macOS](#tab/unix)
6257

6358
Edit your `.bash_profile`, and add the environment variable:
6459

@@ -70,7 +65,7 @@ export AUTOSUGGEST_ENDPOINT=<replace-with-your-autosuggest-api-endpoint>
7065
After you add the environment variable, run `source .bash_profile` from your console window to make the changes effective.
7166
***
7267

73-
### Create a new C# application
68+
## Create a new C# application
7469

7570
Create a new .NET Core application in your preferred editor or IDE.
7671

@@ -106,7 +101,7 @@ using System.Text;
106101
using System.Threading.Tasks;
107102
```
108103

109-
In the `Program` class, create variables for your resource's Azure endpoint and key. If you created the environment variable after you launched the application, you will need to close and reopen the editor, IDE, or shell running it to access the variable.
104+
In the `Program` class, create variables for your resource's Azure endpoint and key. If you created the environment variable after you launched the application, you'll need to close and reopen the editor, IDE, or shell running it to access the variable.
110105

111106
```csharp
112107
private const string key_var = "AUTOSUGGEST_SUBSCRIPTION_KEY";
@@ -117,7 +112,7 @@ private const string endpoint_var = "AUTOSUGGEST_ENDPOINT";
117112
private static readonly string endpoint = Environment.GetEnvironmentVariable(endpoint_var);
118113
```
119114

120-
In the application's `Main` method, add the following method calls, which you will define later.
115+
In the application's `Main` method, add the following method calls, which you'll define later.
121116

122117
```csharp
123118
static void Main(string[] args)
@@ -128,7 +123,7 @@ static void Main(string[] args)
128123
}
129124
```
130125

131-
### Install the client library
126+
## Install the client library
132127

133128
Within the application directory, install the Bing Autosuggest client library for .NET with the following command:
134129

@@ -143,12 +138,12 @@ If you're using the Visual Studio IDE, the client library is available as a down
143138
These code snippets show you how to do the following tasks with the Bing Autosuggest client library for .NET:
144139

145140
* [Authenticate the client](#authenticate-the-client)
146-
* [Send an autosuggest request](#send-an-autosuggest-request)
141+
* [Send an Autosuggest request](#send-an-autosuggest-request)
147142

148-
## Authenticate the client
143+
### Authenticate the client
149144

150145
> [!NOTE]
151-
> This quickstart assumes you've [created an environment variable](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account#configure-an-environment-variable-for-authentication) for your Bing Autosuggest key, named `AUTOSUGGEST_SUBSCRIPTION_KEY`, and one for your endpoint named `AUTOSUGGEST_ENDPOINT`.
146+
> This quickstart assumes you've [created an environment variable](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account#configure-an-environment-variable-for-authentication) for your Bing Autosuggest key, named `AUTOSUGGEST_SUBSCRIPTION_KEY`, and one for your endpoint, named `AUTOSUGGEST_ENDPOINT`.
152147
153148

154149
In a new asynchronous method, instantiate a client with your endpoint and key. Create an [ApiKeyServiceClientCredentials](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.apikeyserviceclientcredentials?view=azure-dotnet) object with your key, and use it with your endpoint to create an [AutosuggestClient](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.autosuggestclient?view=azure-dotnet) object.
@@ -165,9 +160,9 @@ async static Task RunQuickstart()
165160
}
166161
```
167162

168-
## Send an autosuggest request
163+
### Send an Autosuggest request
169164

170-
In the same method, use the client's [AutoSuggestMethodAsync](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.autosuggestclientextensions.autosuggestmethodasync?view=azure-dotnet#Microsoft_Azure_CognitiveServices_Search_AutoSuggest_AutoSuggestClientExtensions_AutoSuggestMethodAsync_Microsoft_Azure_CognitiveServices_Search_AutoSuggest_IAutoSuggestClient_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_Collections_Generic_IList_System_String__System_Threading_CancellationToken_) method to send a query to Bing. Then iterate over the [Suggestions](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.models.suggestions?view=azure-dotnet) response, and print the first suggestion.
165+
In the same method, use the client's [AutoSuggestMethodAsync](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.autosuggestclientextensions.autosuggestmethodasync?view=azure-dotnet#Microsoft_Azure_CognitiveServices_Search_AutoSuggest_AutoSuggestClientExtensions_AutoSuggestMethodAsync_Microsoft_Azure_CognitiveServices_Search_AutoSuggest_IAutoSuggestClient_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_Collections_Generic_IList_System_String__System_Threading_CancellationToken_) method to send a query to Bing. Then, iterate over the [Suggestions](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.models.suggestions?view=azure-dotnet) response, and print the first suggestion.
171166

172167
```csharp
173168
var result = await client.AutoSuggestMethodAsync("xb");
@@ -203,10 +198,10 @@ dotnet run
203198

204199
## Clean up resources
205200

206-
If you want to clean up and remove a Cognitive Services subscription, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it.
201+
If you want to clean up and remove a Cognitive Services subscription, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it:
207202

208-
* [Portal](../../../cognitive-services-apis-create-account.md#clean-up-resources)
209-
* [Azure CLI](../../../cognitive-services-apis-create-account-cli.md#clean-up-resources)
203+
* [Delete a resource group in the Azure portal](../../../cognitive-services-apis-create-account.md#clean-up-resources).
204+
* [Delete a resource group in the Azure CLI](../../../cognitive-services-apis-create-account-cli.md#clean-up-resources).
210205

211206
## Next steps
212207

articles/cognitive-services/Bing-Autosuggest/includes/quickstarts/autosuggest-client-library-go.md

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: aahill
66
manager: nitinme
77
ms.service: cognitive-services
88
ms.topic: include
9-
ms.date: 04/06/2020
9+
ms.date: 05/06/2020
1010
ms.author: aahi
1111
---
1212

@@ -18,31 +18,26 @@ Use the Bing Autosuggest client library for Go to get search suggestions based o
1818

1919
## Prerequisites
2020

21-
* An Azure subscription - [create one for free](https://azure.microsoft.com/free/)
22-
* The latest version of [Go](https://golang.org/dl/)
23-
24-
## Setting up
25-
26-
### Create an Azure resource
21+
* An Azure subscription. If you don't already have an Azure subscription, [you can create one for free](https://azure.microsoft.com/free/).
22+
* The latest version of [Go](https://golang.org/dl/).
2723

2824
Begin using the Bing Autosuggest client library by creating an Azure resource. Choose the resource type below that's right for you:
2925

3026
[!INCLUDE [cognitive-services-bing-autosuggest-signup-requirements](~/includes/cognitive-services-bing-autosuggest-signup-requirements.md)]
3127

32-
### Create an environment variable
28+
## Create environment variables
3329

3430
>[!NOTE]
3531
> The endpoints for non-trial resources created after July 1, 2019 use the custom subdomain format shown below. For more information and a complete list of regional endpoints, see [Custom subdomain names for Cognitive Services](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-custom-subdomains).
3632
3733
Using your key and endpoint from the resource you created, create two environment variables for authentication:
3834
<!-- replace the below variable names with the names expected in the code sample.-->
39-
* `AUTOSUGGEST_SUBSCRIPTION_KEY` - The resource key for authenticating your requests.
40-
* `AUTOSUGGEST_ENDPOINT` - The resource endpoint for sending API requests. It will look like this:
41-
* `https://<your-custom-subdomain>.api.cognitive.microsoft.com`
35+
* `AUTOSUGGEST_SUBSCRIPTION_KEY`: The resource key for authenticating your requests.
36+
* `AUTOSUGGEST_ENDPOINT`: The resource endpoint for sending API requests. It should look like this: `https://<your-custom-subdomain>.api.cognitive.microsoft.com`
4237

4338
Use the instructions for your operating system.
4439
<!-- replace the below endpoint and key examples -->
45-
#### [Windows](#tab/windows)
40+
### [Windows](#tab/windows)
4641

4742
```console
4843
setx BING_AUTOSUGGEST_SUBSCRIPTION_KEY <replace-with-your-autosuggest-api-key>
@@ -51,7 +46,7 @@ setx BING_AUTOSUGGEST_ENDPOINT <replace-with-your-autosuggest-api-endpoint>
5146

5247
After you add the environment variable, restart the console window.
5348

54-
#### [Linux](#tab/linux)
49+
### [Linux](#tab/linux)
5550

5651
```bash
5752
export AUTOSUGGEST_SUBSCRIPTION_KEY=<replace-with-your-autosuggest-api-key>
@@ -60,7 +55,7 @@ export AUTOSUGGEST_ENDPOINT=<replace-with-your-autosuggest-api-endpoint>
6055

6156
After you add the environment variable, run `source ~/.bashrc` from your console window to make the changes effective.
6257

63-
#### [macOS](#tab/unix)
58+
### [macOS](#tab/unix)
6459

6560
Edit your `.bash_profile`, and add the environment variable:
6661

@@ -72,13 +67,13 @@ export AUTOSUGGEST_ENDPOINT=<replace-with-your-autosuggest-api-endpoint>
7267
After you add the environment variable, run `source .bash_profile` from your console window to make the changes effective.
7368
***
7469

75-
### Create a new Go project
70+
## Create a new Go project
7671

7772
In a console window (cmd, PowerShell, Terminal, Bash), create a new workspace for your Go project and navigate to it. Your workspace will contain three folders:
7873

79-
* **src** - This directory contains source code and packages. Any packages installed with the `go get` command will reside here.
80-
* **pkg** - This directory contains the compiled Go package objects. These files all have an `.a` extension.
81-
* **bin** - This directory contains the binary executable files that are created when you run `go install`.
74+
* **src**: This directory contains source code and packages. Any packages installed with the `go get` command will reside here.
75+
* **pkg**: This directory contains the compiled Go package objects. These files all have an `.a` extension.
76+
* **bin**: This directory contains the binary executable files that are created when you run `go install`.
8277

8378
> [!TIP]
8479
> Learn more about the structure of a [Go workspace](https://golang.org/doc/code.html#Workspaces). This guide includes information for setting `$GOPATH` and `$GOROOT`.
@@ -90,7 +85,7 @@ $ mkdir -p my-app/{src, bin, pkg}
9085
$ cd my-app
9186
```
9287

93-
### Install the client library for Go
88+
## Install the client library for Go
9489

9590
Now, let's install the client library for Go:
9691

@@ -104,7 +99,7 @@ or if you use dep, within your repo run:
10499
$ dep ensure -add <library-location-or-url>
105100
```
106101

107-
### Create your Go application
102+
## Create your Go application
108103

109104
Next, let's create a file named `src/sample-app.go`:
110105

@@ -113,7 +108,7 @@ $ cd src
113108
$ touch sample-app.go
114109
```
115110

116-
Open `sample-app.go` and add the package name and import the following libraries:
111+
Open `sample-app.go`, add the package name, and then import the following libraries:
117112

118113
```Go
119114
package main
@@ -128,7 +123,7 @@ import (
128123
)
129124
```
130125

131-
Create a function named `main`. Then create environment variables for your Bing Autosuggest key and endpoint.
126+
Create a function named `main`. Then, create environment variables for your Bing Autosuggest key and endpoint:
132127

133128
```go
134129
func main() {
@@ -152,7 +147,7 @@ These code samples show you how to complete basic tasks using the Bing Autosugge
152147
* [Authenticate the client](#authenticate-the-client)
153148
* [Send an API request](#send-an-api-request)
154149

155-
## Authenticate the client
150+
### Authenticate the client
156151

157152
> [!NOTE]
158153
> This quickstart assumes you've [created an environment variable](https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account#configure-an-environment-variable-for-authentication) for your Bing autosuggest key, named `BING_AUTOSUGGEST_SUBSCRIPTION_KEY`, and one for your endpoint named `BING_AUTOSUGGEST_ENDPOINT`.
@@ -169,9 +164,9 @@ client.Authorizer = autorest.NewCognitiveServicesAuthorizer(subscription_key)
169164
client.Endpoint = endpoint
170165
```
171166

172-
## Send an API request
167+
### Send an API request
173168

174-
In the same method, use the client's [AutoSuggestMethodAsync](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.autosuggestclientextensions.autosuggestmethodasync?view=azure-dotnet#Microsoft_Azure_CognitiveServices_Search_AutoSuggest_AutoSuggestClientExtensions_AutoSuggestMethodAsync_Microsoft_Azure_CognitiveServices_Search_AutoSuggest_IAutoSuggestClient_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_Collections_Generic_IList_System_String__System_Threading_CancellationToken_) method to send a query to Bing. Then iterate over the [Suggestions](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.models.suggestions?view=azure-dotnet) response, and print the first suggestion.
169+
In the same method, use the client's [AutoSuggestMethodAsync](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.autosuggestclientextensions.autosuggestmethodasync?view=azure-dotnet#Microsoft_Azure_CognitiveServices_Search_AutoSuggest_AutoSuggestClientExtensions_AutoSuggestMethodAsync_Microsoft_Azure_CognitiveServices_Search_AutoSuggest_IAutoSuggestClient_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_String_System_Collections_Generic_IList_System_String__System_Threading_CancellationToken_) method to send a query to Bing. Then, iterate over the [Suggestions](https://docs.microsoft.com/dotnet/api/microsoft.azure.cognitiveservices.search.autosuggest.models.suggestions?view=azure-dotnet) response, and print the first suggestion.
175170

176171
```Go
177172
// This should return the query suggestion "xbox."
@@ -209,8 +204,8 @@ go run sample-app.go
209204

210205
If you want to clean up and remove a Cognitive Services subscription, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it.
211206

212-
* [Portal](../../../cognitive-services-apis-create-account.md#clean-up-resources)
213-
* [Azure CLI](../../../cognitive-services-apis-create-account-cli.md#clean-up-resources)
207+
* [Delete a resource group in the Azure portal](../../../cognitive-services-apis-create-account.md#clean-up-resources).
208+
* [Delete a resource group in the Azure CLI](../../../cognitive-services-apis-create-account-cli.md#clean-up-resources).
214209

215210
## Next steps
216211

0 commit comments

Comments
 (0)