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
Copy file name to clipboardExpand all lines: articles/search/search-get-started-rbac.md
+12-14Lines changed: 12 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,12 +7,12 @@ ms.author: heidist
7
7
ms.service: azure-ai-search
8
8
9
9
ms.topic: quickstart
10
-
ms.date: 11/29/2024
10
+
ms.date: 12/03/2024
11
11
---
12
12
13
13
# Quickstart: Connect without keys
14
14
15
-
Configure Azure AI Search to use Microsoft Entra ID authentication and role-based access control (RBAC) so that you can connect from your local system with your personal identity, using Jupyter notebooks or a REST client to interact with your search service.
15
+
Configure Azure AI Search to use Microsoft Entra ID authentication and role-based access control (RBAC) so that you can connect from your local system without API keys, using Jupyter notebooks or a REST client to interact with your search service.
16
16
17
17
If you stepped through other quickstarts that connect using API keys, this quickstart shows you how to switch to identity-based authentication so that you can avoid hard-coded keys in your example code.
18
18
@@ -34,7 +34,7 @@ You need this step if you have more than one subscription or tenant.
34
34
35
35
1. Notice the subscription name and ID in **Overview** > **Essentials**.
36
36
37
-
1. Now select the subscription name to confirm the parent management group (tenant ID) on the next page.
37
+
1. Now select the subscription name to show the parent management group (tenant ID) on the next page.
38
38
39
39
:::image type="content" source="media/search-get-started-rbac/select-subscription-name.png" lightbox="media/search-get-started-rbac/select-subscription-name.png" alt-text="Screenshot of the portal page providing the subscription name":::
40
40
@@ -52,12 +52,6 @@ You need this step if you have more than one subscription or tenant.
52
52
az login --tenant <your-tenant-id>
53
53
```
54
54
55
-
1. Verify your tenant ID:
56
-
57
-
```azurecli
58
-
az account show --query tenantId --output tsv
59
-
```
60
-
61
55
## Step 2: Configure Azure AI Search for RBAC
62
56
63
57
1. Sign in to the [Azure portal](https://portal.azure.com) and navigate to your Azure AI Search service.
@@ -122,19 +116,21 @@ az login
122
116
123
117
### Using a REST client
124
118
125
-
[Several quickstarts](search-get-started-vector.md) and tutorials use a REST client, such as Visual Studio Code with the REST extension. Here's how you connect to Azure AI Search from Visual Studio Code.
119
+
Several quickstarts and tutorials use a REST client, such as Visual Studio Code with the REST extension. Here's how you connect to Azure AI Search from Visual Studio Code.
120
+
121
+
You should have a `.rest`or`.http`file, similar to the one described in [Quickstart: Vector search](search-get-started-vector.md).
126
122
127
-
1. Get a personal identity token:
123
+
1. Get an access token:
128
124
129
125
```azurecli
130
126
az account get-access-token --scope https://search.azure.com/.default --query accessToken --output tsv
131
127
```
132
128
133
-
1.Set variables used for the connection, pasting the full search service endpoint and the token you got in the previous step. Make sure neither value is quote-enclosed.
129
+
1.At the top of your file, set variables used for the connection, pasting the full search service endpoint and the access token you got in the previous step. Your variables should look similar to the following example. Notice the values aren't quote-enclosed.
Copy file name to clipboardExpand all lines: articles/search/search-get-started-vector.md
+37-99Lines changed: 37 additions & 99 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,14 +8,14 @@ ms.service: azure-ai-search
8
8
ms.custom:
9
9
- ignite-2023
10
10
ms.topic: quickstart
11
-
ms.date: 10/31/2024
11
+
ms.date: 12/03/2024
12
12
---
13
13
14
14
# Quickstart: Vector search by using REST
15
15
16
16
Learn how to use the [Search REST APIs](/rest/api/searchservice) to create, load, and query vectors in Azure AI Search.
17
17
18
-
In Azure AI Search, a [vector store](vector-store.md) has an index schema that defines vector and nonvector fields, a vector configuration for algorithms that create the embedding space, and settings on vector field definitions that are used in query requests. The [Create Index](/rest/api/searchservice/indexes/create-or-update) API creates the vector store.
18
+
In Azure AI Search, a [vector store](vector-store.md) has an index schema that defines vector and nonvector fields, a vector search configuration for algorithms that create the embedding space, and settings on vector field definitions that are evaluated at query time. The [Create Index](/rest/api/searchservice/indexes/create-or-update) REST API creates the vector store.
19
19
20
20
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
21
21
@@ -24,106 +24,49 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
24
24
25
25
## Prerequisites
26
26
27
-
-[Visual Studio Code](https://code.visualstudio.com/download) with a [REST client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client). If you need help with getting started, see [Quickstart: Text search using REST](search-get-started-rest.md).
27
+
-[Visual Studio Code](https://code.visualstudio.com/download) with a [REST client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client).
28
28
29
29
-[Azure AI Search](search-what-is-azure-search.md), in any region and on any tier. You can use the Free tier for this quickstart, but Basic or higher is recommended for larger data files. [Create](search-create-service-portal.md) or [find an existing Azure AI Search resource](https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Search%2FsearchServices) under your current subscription.
30
30
31
31
Most existing services support vector search. For a small subset of services created prior to January 2019, an index that contains vector fields fails on creation. In this situation, a new service must be created.
32
32
33
33
- Optionally, to run the query example that invokes [semantic reranking](semantic-search-overview.md), your search service must be the Basic tier or higher, with [semantic ranker enabled](semantic-how-to-enable-disable.md).
34
34
35
-
- Optionally, an [Azure OpenAI](https://aka.ms/oai/access) resource with a deployment of `text-embedding-ada-002`. The source `.rest` file includes an optional step for generating new text embeddings, but we provide pregenerated embeddings so that you can omit this dependency.
36
-
37
35
## Download files
38
36
39
37
[Download a REST sample](https://github.com/Azure-Samples/azure-search-rest-samples/tree/main/Quickstart-vectors) from GitHub to send the requests in this quickstart. For more information, see [Downloading files from GitHub](https://docs.github.com/get-started/start-your-journey/downloading-files-from-github).
40
38
41
39
You can also start a new file on your local system and create requests manually by using the instructions in this article.
42
40
43
-
## Get a search service endpoint
41
+
## Get a search endpoint and an API key
42
+
43
+
You can find the search service endpoint and API keys in the Azure portal. You're pasting these values into a `.rest` or `.http` file in the next step.
44
44
45
-
You can find the search service endpoint in the Azure portal.
45
+
Requests to the search endpoint must be authenticated and authorized. You can use API keys or roles for this task. Keys are easier to start with, but roles are more secure. Although we use API keys for this quickstart, we recommend [switching to a keyless connection](search-get-started-rbac.md).
46
46
47
47
1. Sign in to the [Azure portal](https://portal.azure.com) and [find your search service](https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Search%2FsearchServices).
48
48
49
49
1. On the **Overview** home page, find the URL. An example endpoint might look like `https://mydemo.search.windows.net`.
50
50
51
51
:::image type="content" source="media/search-get-started-rest/get-endpoint.png" lightbox="media/search-get-started-rest/get-endpoint.png" alt-text="Screenshot of the URL property on the overview page.":::
52
52
53
-
You're pasting this endpoint into the `.rest` or `.http` file in a later step.
54
-
55
-
## Configure access
56
-
57
-
Requests to the search endpoint must be authenticated and authorized. You can use API keys or roles for this task. Keys are easier to start with, but roles are more secure.
58
-
59
-
For a role-based connection, the following instructions have you connecting to Azure AI Search under your identity, not the identity of a client app.
60
-
61
-
### Option 1: Use keys
62
-
63
-
Select **Settings** > **Keys** and then copy an admin key. Admin keys are used to add, modify, and delete objects. There are two interchangeable admin keys. Copy either one. For more information, see [Connect to Azure AI Search using key authentication](search-security-api-keys.md).
64
-
65
-
:::image type="content" source="media/search-get-started-rest/get-api-key.png" lightbox="media/search-get-started-rest/get-api-key.png" alt-text="Screenshot that shows the API keys in the Azure portal.":::
66
-
67
-
You're pasting this key into the `.rest` or `.http` file in a later step.
68
-
69
-
### Option 2: Use roles
70
-
71
-
Make sure your search service is [configured for role-based access](search-security-enable-roles.md). You must have preconfigured [role-assignments for developer access](search-security-rbac.md#assign-roles-for-development). Your role assignments must grant permission to create, load, and query a search index.
72
-
73
-
In this section, obtain your personal identity token using either the Azure CLI, Azure PowerShell, or the Azure portal.
74
-
75
-
#### [Azure CLI](#tab/azure-cli)
76
-
77
-
1. Sign in to Azure CLI.
78
-
79
-
```azurecli
80
-
az login
81
-
```
82
-
83
-
1. Get your personal identity token.
84
-
85
-
```azurecli
86
-
az account get-access-token --scope https://search.azure.com/.default
1. Select **Settings** > **Keys**. Either **API keys** or **Both** must be enabled. [Admin API keys](search-security-api-keys.md) are used to add, modify, and delete objects. There are two interchangeable admin keys. Copy either one.
104
54
105
-
Use the steps found here: [find the user object ID](/partner-center/find-ids-and-domain-names#find-the-user-object-id) in the Azure portal.
106
-
107
-
---
108
-
109
-
You're pasting your personal identity token into the `.rest` or `.http` file in a later step.
110
-
111
-
> [!NOTE]
112
-
> This section assumes you're using a local client that connects to Azure AI Search on your behalf. An alternative approach is [getting a token for the client app](/entra/identity-platform/v2-oauth2-client-creds-grant-flow), assuming your application is [registered](/entra/identity-platform/quickstart-register-app) with Microsoft Entra ID.
55
+
:::image type="content" source="media/search-get-started-rest/get-api-key.png" lightbox="media/search-get-started-rest/get-api-key.png" alt-text="Screenshot that shows the API keys in the Azure portal.":::
113
56
114
57
## Create a vector index
115
58
116
59
[Create Index (REST)](/rest/api/searchservice/indexes/create) creates a vector index and sets up the physical data structures on your search service.
117
60
118
61
The index schema is organized around hotel content. Sample data consists of vector and nonvector names and descriptions of seven fictitious hotels. This schema includes configurations for vector indexing and queries, and for semantic ranking.
119
62
120
-
1. Open a new text file in Visual Studio Code.
63
+
1.Create a new text file in Visual Studio Code.
121
64
122
-
1. Set variables to the values you collected earlier. This example uses a personal identity token.
65
+
1.At the top of the file, add variables for the values you collected earlier.
123
66
124
67
```http
125
68
@baseUrl = PUT-YOUR-SEARCH-SERVICE-URL-HERE
126
-
@token = PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HERE
69
+
@apiKey = PUT-YOUR-ADMIN-KEY-HERE
127
70
```
128
71
129
72
1. Save the file with a `.rest` or `.http` file extension.
@@ -134,7 +77,7 @@ The index schema is organized around hotel content. Sample data consists of vect
134
77
### Create a new index
135
78
POST {{baseUrl}}/indexes?api-version=2023-11-01 HTTP/1.1
136
79
Content-Type: application/json
137
-
Authorization: Bearer {{token}}
80
+
api-key: {{apiKey}}
138
81
139
82
{
140
83
"name": "hotels-vector-quickstart",
@@ -237,23 +180,6 @@ The index schema is organized around hotel content. Sample data consists of vect
237
180
"efSearch": 500,
238
181
"metric": "cosine"
239
182
}
240
-
},
241
-
{
242
-
"name": "my-hnsw-vector-config-2",
243
-
"kind": "hnsw",
244
-
"hnswParameters":
245
-
{
246
-
"m": 4,
247
-
"metric": "euclidean"
248
-
}
249
-
},
250
-
{
251
-
"name": "my-eknn-vector-config",
252
-
"kind": "exhaustiveKnn",
253
-
"exhaustiveKnnParameters":
254
-
{
255
-
"metric": "cosine"
256
-
}
257
183
}
258
184
],
259
185
"profiles": [
@@ -284,13 +210,16 @@ The index schema is organized around hotel content. Sample data consists of vect
284
210
}
285
211
```
286
212
287
-
1. Select **Send request**. Recall that you need the REST client to send requests. You should have an `HTTP/1.1 201 Created` response. The response body should include the JSON representation of the index schema.
213
+
1. Save the file again, and then select **Send request**. You should have an `HTTP/1.1 201 Created` response. The response body should include the JSON representation of the index schema.
288
214
289
-
Key points:
215
+
Key takeaways about this REST API:
290
216
291
217
- The `fields` collection includes a required key field and text and vector fields (such as `Description` and `DescriptionVector`) for text and vector search. Colocating vector and nonvector fields in the same index enables hybrid queries. For instance, you can combine filters, text search with semantic ranking, and vectors into a single query operation.
218
+
292
219
- Vector fields must be `type: Collection(Edm.Single)` with `dimensions` and `vectorSearchProfile` properties.
220
+
293
221
- The `vectorSearch` section is an array of approximate nearest neighbor algorithm configurations and profiles. Supported algorithms include hierarchical navigable small world and exhaustive k-nearest neighbor. For more information, see [Relevance scoring in vector search](vector-search-ranking.md).
222
+
294
223
- [Optional]: The `semantic` configuration enables reranking of search results. You can rerank results in queries of type `semantic` for string fields that are specified in the configuration. To learn more, see [Semantic ranking overview](semantic-search-overview.md).
295
224
296
225
## Upload documents
@@ -302,11 +231,15 @@ The URI is extended to include the `docs` collection and the `index` operation.
302
231
> [!IMPORTANT]
303
232
> The following example isn't runnable code. For readability, we excluded vector values because each one contains 1,536 embeddings, which is too long for this article. If you want to try this step, copy runnable code from the [sample on GitHub](https://github.com/Azure-Samples/azure-search-rest-samples/tree/main/Quickstart-vectors).
304
233
234
+
1. Paste in a valid request that uploads documents, similar to the example below.
235
+
236
+
1. Save the file, and then select **Send request**. You should have an `HTTP/1.1 201 Created` response. The response body should include the JSON representation of the search documents.
237
+
305
238
```http
306
239
### Upload documents
307
240
POST {{baseUrl}}/indexes/hotels-quickstart-vectors/docs/index?api-version=2023-11-01 HTTP/1.1
- Documents in the payload consist of fields defined in the index schema.
373
+
440
374
- Vector fields contain floating point values. The dimensions attribute has a minimum of 2 and a maximum of 3,072 floating point values each. This quickstart sets the dimensions attribute to 1,536 because that's the size of embeddings generated by the Azure OpenAI **text-embedding-ada-002** model.
441
375
442
376
## Run queries
@@ -462,13 +396,13 @@ The vector query string is semantically similar to the search string, but it inc
462
396
463
397
### Single vector search
464
398
465
-
1. Paste in a POST request to query the search index. Then select **Send request**. The URI is extended to include the `/docs/search` operator.
399
+
1. Paste in a POST request to query the search index. Save the file. Then select **Send request**. The URI is extended to include the `/docs/search` operator.
466
400
467
401
```http
468
402
### Run a query
469
403
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
470
404
Content-Type: application/json
471
-
Authorization: Bearer {{token}}
405
+
api-key: {{apiKey}}
472
406
473
407
{
474
408
"count": true,
@@ -547,7 +481,7 @@ You can add filters, but the filters are applied to the nonvector content in you
547
481
### Run a vector query with a filter
548
482
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
549
483
Content-Type: application/json
550
-
Authorization: Bearer {{token}}
484
+
api-key: {{apiKey}}
551
485
552
486
{
553
487
"count": true,
@@ -620,7 +554,7 @@ Hybrid search consists of keyword queries and vector queries in a single search
620
554
### Run a hybrid query
621
555
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
622
556
Content-Type: application/json
623
-
Authorization: Bearer {{token}}
557
+
api-key: {{apiKey}}
624
558
625
559
{
626
560
"count": true,
@@ -767,7 +701,7 @@ Here's the last query in the collection. This hybrid query with semantic ranking
767
701
### Run a hybrid query
768
702
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
769
703
Content-Type: application/json
770
-
Authorization: Bearer {{token}}
704
+
api-key: {{apiKey}}
771
705
772
706
{
773
707
"count": true,
@@ -854,10 +788,12 @@ Here's the last query in the collection. This hybrid query with semantic ranking
854
788
}
855
789
```
856
790
857
-
Key points:
791
+
Key takeaways about this REST API:
858
792
859
793
- Vector search is specified through the `vectors.value` property. Keyword search is specified through the `search` property.
794
+
860
795
- In a hybrid search, you can integrate vector search with full-text search over keywords. Filters, spell check, and semantic ranking apply to textual content only, and not vectors. In this final query, there's no semantic `answer` because the system didn't produce one that was sufficiently strong.
796
+
861
797
- Actual results include more detail, including semantic captions and highlights. Results were modified for readability. To get the full structure of the response, run the request in the REST client.
862
798
863
799
## Clean up
@@ -872,9 +808,11 @@ You can also try this `DELETE` command:
As a next step, we recommend that you review the demo code for [Python](https://github.com/Azure/azure-search-vector-samples/tree/main/demo-python), [C#](https://github.com/Azure/azure-search-vector-samples/tree/main/demo-dotnet), or [JavaScript](https://github.com/Azure/azure-search-vector-samples/tree/main/demo-javascript).
816
+
As a next step, we recommend learning how to invoke REST API calls [without API keys](search-get-started-rbac.md).
817
+
818
+
You might also want to review the demo code for [Python](https://github.com/Azure/azure-search-vector-samples/tree/main/demo-python), [C#](https://github.com/Azure/azure-search-vector-samples/tree/main/demo-dotnet), or [JavaScript](https://github.com/Azure/azure-search-vector-samples/tree/main/demo-javascript).
0 commit comments