Skip to content

Commit 7a2bb21

Browse files
authored
Merge pull request #1791 from HeidiSteen/heidist-uuf
[azure search] rbac updates
2 parents 3f9cd62 + 9b41348 commit 7a2bb21

File tree

3 files changed

+50
-114
lines changed

3 files changed

+50
-114
lines changed

articles/search/search-get-started-rbac.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ ms.author: heidist
77
ms.service: azure-ai-search
88

99
ms.topic: quickstart
10-
ms.date: 11/29/2024
10+
ms.date: 12/03/2024
1111
---
1212

1313
# Quickstart: Connect without keys
1414

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.
1616

1717
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.
1818

@@ -34,7 +34,7 @@ You need this step if you have more than one subscription or tenant.
3434

3535
1. Notice the subscription name and ID in **Overview** > **Essentials**.
3636

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.
3838

3939
:::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":::
4040

@@ -52,12 +52,6 @@ You need this step if you have more than one subscription or tenant.
5252
az login --tenant <your-tenant-id>
5353
```
5454

55-
1. Verify your tenant ID:
56-
57-
```azurecli
58-
az account show --query tenantId --output tsv
59-
```
60-
6155
## Step 2: Configure Azure AI Search for RBAC
6256

6357
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
122116

123117
### Using a REST client
124118

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).
126122

127-
1. Get a personal identity token:
123+
1. Get an access token:
128124

129125
```azurecli
130126
az account get-access-token --scope https://search.azure.com/.default --query accessToken --output tsv
131127
```
132128

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.
134130

135131
```REST
136-
@baseUrl = PUT-YOUR-SEARCH-SERVICE-URL-HERE
137-
@token = PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HERE
132+
@baseUrl = https://contoso.search.search.windows.net
133+
@token = <a long GUID>
138134
```
139135
140136
1. Specify the authorization bearer token in a REST call:
@@ -153,6 +149,8 @@ az login
153149
}
154150
```
155151

152+
If the call fails, revisit the previous steps to make sure you didn't skip any. You might also want to restart your device.
153+
156154
## Additional configuration
157155

158156
Configure a managed identity for outbound connections:

articles/search/search-get-started-vector.md

Lines changed: 37 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ ms.service: azure-ai-search
88
ms.custom:
99
- ignite-2023
1010
ms.topic: quickstart
11-
ms.date: 10/31/2024
11+
ms.date: 12/03/2024
1212
---
1313

1414
# Quickstart: Vector search by using REST
1515

1616
Learn how to use the [Search REST APIs](/rest/api/searchservice) to create, load, and query vectors in Azure AI Search.
1717

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.
1919

2020
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
2121

@@ -24,106 +24,49 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
2424
2525
## Prerequisites
2626

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).
2828

2929
- [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.
3030

3131
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.
3232

3333
- 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).
3434

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-
3735
## Download files
3836

3937
[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).
4038

4139
You can also start a new file on your local system and create requests manually by using the instructions in this article.
4240

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.
4444

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).
4646

4747
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).
4848

4949
1. On the **Overview** home page, find the URL. An example endpoint might look like `https://mydemo.search.windows.net`.
5050

5151
:::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.":::
5252

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
87-
```
88-
89-
#### [Azure PowerShell](#tab/azure-powershell)
90-
91-
1. Sign in with PowerShell.
92-
93-
```azurepowershell
94-
Connect-AzAccount
95-
```
96-
97-
1. Get your personal identity token.
98-
99-
```azurepowershell
100-
Get-AzAccessToken -ResourceUrl https://search.azure.com
101-
```
102-
103-
#### [Azure portal](#tab/portal)
53+
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.
10454

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.":::
11356

11457
## Create a vector index
11558

11659
[Create Index (REST)](/rest/api/searchservice/indexes/create) creates a vector index and sets up the physical data structures on your search service.
11760

11861
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.
11962

120-
1. Open a new text file in Visual Studio Code.
63+
1. Create a new text file in Visual Studio Code.
12164

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.
12366

12467
```http
12568
@baseUrl = PUT-YOUR-SEARCH-SERVICE-URL-HERE
126-
@token = PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HERE
69+
@apiKey = PUT-YOUR-ADMIN-KEY-HERE
12770
```
12871

12972
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
13477
### Create a new index
13578
POST {{baseUrl}}/indexes?api-version=2023-11-01 HTTP/1.1
13679
Content-Type: application/json
137-
Authorization: Bearer {{token}}
80+
api-key: {{apiKey}}
13881
13982
{
14083
"name": "hotels-vector-quickstart",
@@ -237,23 +180,6 @@ The index schema is organized around hotel content. Sample data consists of vect
237180
"efSearch": 500,
238181
"metric": "cosine"
239182
}
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-
}
257183
}
258184
],
259185
"profiles": [
@@ -284,13 +210,16 @@ The index schema is organized around hotel content. Sample data consists of vect
284210
}
285211
```
286212
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.
288214
289-
Key points:
215+
Key takeaways about this REST API:
290216
291217
- 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+
292219
- Vector fields must be `type: Collection(Edm.Single)` with `dimensions` and `vectorSearchProfile` properties.
220+
293221
- 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+
294223
- [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).
295224
296225
## Upload documents
@@ -302,11 +231,15 @@ The URI is extended to include the `docs` collection and the `index` operation.
302231
> [!IMPORTANT]
303232
> 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).
304233
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+
305238
```http
306239
### Upload documents
307240
POST {{baseUrl}}/indexes/hotels-quickstart-vectors/docs/index?api-version=2023-11-01 HTTP/1.1
308241
Content-Type: application/json
309-
Authorization: Bearer {{token}}
242+
api-key: {{apiKey}}
310243
311244
{
312245
"value": [
@@ -434,9 +367,10 @@ Authorization: Bearer {{token}}
434367
}
435368
```
436369

437-
Key points:
370+
Key takeaways about this REST API:
438371

439372
- Documents in the payload consist of fields defined in the index schema.
373+
440374
- 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.
441375

442376
## Run queries
@@ -462,13 +396,13 @@ The vector query string is semantically similar to the search string, but it inc
462396
463397
### Single vector search
464398

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.
466400

467401
```http
468402
### Run a query
469403
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
470404
Content-Type: application/json
471-
Authorization: Bearer {{token}}
405+
api-key: {{apiKey}}
472406
473407
{
474408
"count": true,
@@ -547,7 +481,7 @@ You can add filters, but the filters are applied to the nonvector content in you
547481
### Run a vector query with a filter
548482
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
549483
Content-Type: application/json
550-
Authorization: Bearer {{token}}
484+
api-key: {{apiKey}}
551485
552486
{
553487
"count": true,
@@ -620,7 +554,7 @@ Hybrid search consists of keyword queries and vector queries in a single search
620554
### Run a hybrid query
621555
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
622556
Content-Type: application/json
623-
Authorization: Bearer {{token}}
557+
api-key: {{apiKey}}
624558
625559
{
626560
"count": true,
@@ -767,7 +701,7 @@ Here's the last query in the collection. This hybrid query with semantic ranking
767701
### Run a hybrid query
768702
POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1
769703
Content-Type: application/json
770-
Authorization: Bearer {{token}}
704+
api-key: {{apiKey}}
771705
772706
{
773707
"count": true,
@@ -854,10 +788,12 @@ Here's the last query in the collection. This hybrid query with semantic ranking
854788
}
855789
```
856790
857-
Key points:
791+
Key takeaways about this REST API:
858792
859793
- Vector search is specified through the `vectors.value` property. Keyword search is specified through the `search` property.
794+
860795
- 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+
861797
- 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.
862798
863799
## Clean up
@@ -872,9 +808,11 @@ You can also try this `DELETE` command:
872808
### Delete an index
873809
DELETE {{baseUrl}}/indexes/hotels-vector-quickstart?api-version=2023-11-01 HTTP/1.1
874810
Content-Type: application/json
875-
Authorization: Bearer {{token}}
811+
api-key: {{apiKey}}
876812
```
877813

878814
## Next steps
879815

880-
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

Comments
 (0)