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
+2-2Lines changed: 2 additions & 2 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.
Copy file name to clipboardExpand all lines: articles/search/search-get-started-vector.md
+32-98Lines changed: 32 additions & 98 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,51 @@ 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.
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
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
-
---
53
+
1. Select **Settings** > **Keys** and then copy an admin key. [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.
108
54
109
-
You're pasting your personal identity token into the `.rest` or `.http` file in a later step.
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.":::
110
56
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.
57
+
You're pasting these values into a `.rest` or `.http` file in the next step.
113
58
114
59
## Create a vector index
115
60
116
61
[Create Index (REST)](/rest/api/searchservice/indexes/create) creates a vector index and sets up the physical data structures on your search service.
117
62
118
63
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
64
120
-
1. Open a new text file in Visual Studio Code.
65
+
1.Create a new text file in Visual Studio Code.
121
66
122
-
1. Set variables to the values you collected earlier. This example uses a personal identity token.
67
+
1.At the top of the file, add variables for the values you collected earlier.
123
68
124
69
```http
125
70
@baseUrl = PUT-YOUR-SEARCH-SERVICE-URL-HERE
126
-
@token = PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HERE
71
+
@apiKey = PUT-YOUR-ADMIN-KEY-HERE
127
72
```
128
73
129
74
1. Save the file with a `.rest` or `.http` file extension.
@@ -134,7 +79,7 @@ The index schema is organized around hotel content. Sample data consists of vect
134
79
### Create a new index
135
80
POST {{baseUrl}}/indexes?api-version=2023-11-01 HTTP/1.1
136
81
Content-Type: application/json
137
-
Authorization: Bearer {{token}}
82
+
api-key: {{apiKey}}
138
83
139
84
{
140
85
"name": "hotels-vector-quickstart",
@@ -237,23 +182,6 @@ The index schema is organized around hotel content. Sample data consists of vect
237
182
"efSearch": 500,
238
183
"metric": "cosine"
239
184
}
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
185
}
258
186
],
259
187
"profiles": [
@@ -284,9 +212,9 @@ The index schema is organized around hotel content. Sample data consists of vect
284
212
}
285
213
```
286
214
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.
215
+
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 index schema.
288
216
289
-
Key points:
217
+
Key takeaways about this REST API:
290
218
291
219
- 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.
292
220
- Vector fields must be `type: Collection(Edm.Single)` with `dimensions` and `vectorSearchProfile` properties.
@@ -302,11 +230,15 @@ The URI is extended to include the `docs` collection and the `index` operation.
302
230
> [!IMPORTANT]
303
231
> 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
232
233
+
1. Paste in a valid request that uploads documents, similar to the example below.
234
+
235
+
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.
236
+
305
237
```http
306
238
### Upload documents
307
239
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.
440
372
- 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.
@@ -462,13 +394,13 @@ The vector query string is semantically similar to the search string, but it inc
462
394
463
395
### Single vector search
464
396
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.
397
+
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
398
467
399
```http
468
400
### Run a query
469
401
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
470
402
Content-Type: application/json
471
-
Authorization: Bearer {{token}}
403
+
api-key: {{apiKey}}
472
404
473
405
{
474
406
"count": true,
@@ -547,7 +479,7 @@ You can add filters, but the filters are applied to the nonvector content in you
547
479
### Run a vector query with a filter
548
480
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
549
481
Content-Type: application/json
550
-
Authorization: Bearer {{token}}
482
+
api-key: {{apiKey}}
551
483
552
484
{
553
485
"count": true,
@@ -620,7 +552,7 @@ Hybrid search consists of keyword queries and vector queries in a single search
620
552
### Run a hybrid query
621
553
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
622
554
Content-Type: application/json
623
-
Authorization: Bearer {{token}}
555
+
api-key: {{apiKey}}
624
556
625
557
{
626
558
"count": true,
@@ -767,7 +699,7 @@ Here's the last query in the collection. This hybrid query with semantic ranking
767
699
### Run a hybrid query
768
700
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
769
701
Content-Type: application/json
770
-
Authorization: Bearer {{token}}
702
+
api-key: {{apiKey}}
771
703
772
704
{
773
705
"count": true,
@@ -854,7 +786,7 @@ Here's the last query in the collection. This hybrid query with semantic ranking
854
786
}
855
787
```
856
788
857
-
Key points:
789
+
Key points about this REST API:
858
790
859
791
- Vector search is specified through the `vectors.value` property. Keyword search is specified through the `search` property.
860
792
- 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.
@@ -872,9 +804,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).
812
+
As a next step, we recommend learning how to invoke REST API calls [without API keys](search-get-started-rbac.md).
813
+
814
+
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