You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> 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).
34
30
35
31
Using your key and endpoint from the resource you created, create two environment variables for authentication:
36
32
<!-- 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:
*`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`.
40
35
41
36
Use the instructions for your operating system.
42
37
<!-- replace the below endpoint and key examples -->
After you add the environment variable, run `source .bash_profile` from your console window to make the changes effective.
71
66
***
72
67
73
-
###Create a new C# application
68
+
## Create a new C# application
74
69
75
70
Create a new .NET Core application in your preferred editor or IDE.
76
71
@@ -106,7 +101,7 @@ using System.Text;
106
101
usingSystem.Threading.Tasks;
107
102
```
108
103
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.
Within the application directory, install the Bing Autosuggest client library for .NET with the following command:
134
129
@@ -143,12 +138,12 @@ If you're using the Visual Studio IDE, the client library is available as a down
143
138
These code snippets show you how to do the following tasks with the Bing Autosuggest client library for .NET:
144
139
145
140
*[Authenticate the client](#authenticate-the-client)
146
-
*[Send an autosuggest request](#send-an-autosuggest-request)
141
+
*[Send an Autosuggest request](#send-an-autosuggest-request)
147
142
148
-
## Authenticate the client
143
+
###Authenticate the client
149
144
150
145
> [!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`.
152
147
153
148
154
149
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.
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.
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:
> 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).
36
32
37
33
Using your key and endpoint from the resource you created, create two environment variables for authentication:
38
34
<!-- 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:
*`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`
42
37
43
38
Use the instructions for your operating system.
44
39
<!-- replace the below endpoint and key examples -->
After you add the environment variable, run `source .bash_profile` from your console window to make the changes effective.
73
68
***
74
69
75
-
###Create a new Go project
70
+
## Create a new Go project
76
71
77
72
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:
78
73
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`.
82
77
83
78
> [!TIP]
84
79
> 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`.
@@ -104,7 +99,7 @@ or if you use dep, within your repo run:
104
99
$ dep ensure -add <library-location-or-url>
105
100
```
106
101
107
-
###Create your Go application
102
+
## Create your Go application
108
103
109
104
Next, let's create a file named `src/sample-app.go`:
110
105
@@ -113,7 +108,7 @@ $ cd src
113
108
$ touch sample-app.go
114
109
```
115
110
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:
117
112
118
113
```Go
119
114
package main
@@ -128,7 +123,7 @@ import (
128
123
)
129
124
```
130
125
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:
132
127
133
128
```go
134
129
funcmain() {
@@ -152,7 +147,7 @@ These code samples show you how to complete basic tasks using the Bing Autosugge
152
147
*[Authenticate the client](#authenticate-the-client)
153
148
*[Send an API request](#send-an-api-request)
154
149
155
-
## Authenticate the client
150
+
###Authenticate the client
156
151
157
152
> [!NOTE]
158
153
> 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`.
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.
175
170
176
171
```Go
177
172
// This should return the query suggestion "xbox."
@@ -209,8 +204,8 @@ go run sample-app.go
209
204
210
205
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.
0 commit comments