Skip to content

Commit 2197409

Browse files
authored
Merge pull request #279533 from HeidiSteen/heidist-june27
[azure search] Security sprint, retire old AAD article, add RBAC steps to REST quickstart
2 parents c2eb6aa + ed733bb commit 2197409

11 files changed

+98
-242
lines changed

articles/search/.openpublishing.redirection.search.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
"redirect_url": "/previous-versions/azure/search/search-security-trimming-for-azure-search-with-aad",
66
"redirect_document_id": false
77
},
8+
{
9+
"source_path_from_root": "/articles/search/search-howto-aad.md",
10+
"redirect_url": "/azure/search/keyless-connections",
11+
"redirect_document_id": false
12+
},
813
{
914
"source_path_from_root": "/articles/search/search-synonyms-tutorial-sdk.md",
1015
"redirect_url": "https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample02_Service.md#create-a-synonym-map",

articles/search/TOC.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,7 @@
431431
- name: Connect using API keys
432432
href: search-security-api-keys.md
433433
- name: Code without keys
434-
href: keyless-connections.md
435-
- name: Configure apps for Microsoft Entra ID
436-
href: search-howto-aad.md
434+
href: keyless-connections.md
437435
- name: Create a private endpoint
438436
href: service-create-private-endpoint.md
439437
- name: Troubleshoot private connections

articles/search/keyless-connections.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ Deploy production workloads includes these steps:
323323
324324
### Roles for production workloads
325325
326-
To create your production resources, you need to create a user-assigend [managed identity](/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities?pivots=identity-mi-methods-azp#create-a-user-assigned-managed-identity) then assign that identity to your resources with the correct roles.
326+
To create your production resources, you need to create a [user-assigned managed identity](/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities?pivots=identity-mi-methods-azp#create-a-user-assigned-managed-identity) then assign that identity to your resources with the correct roles.
327327
328328
The following role is suggested for a production application:
329329
@@ -390,4 +390,5 @@ Create environment variables for your deployed and keyless Azure AI Search resou
390390
## Related content
391391

392392
* [Keyless connections developer guide](/azure/developer/intro/passwordless-overview)
393-
* [Azure built-in roles](/azure/role-based-access-control/built-in-roles)
393+
* [Azure built-in roles](/azure/role-based-access-control/built-in-roles)
394+
* [Set environment variables](/azure/ai-services/cognitive-services-environment-variables)
61.4 KB
Loading
53.3 KB
Loading

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

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ ms.author: heidist
99
ms.service: cognitive-search
1010
ms.topic: quickstart
1111
ms.devlang: rest-api
12-
ms.date: 03/14/2024
12+
ms.date: 06/27/2024
1313
ms.custom:
1414
- mode-api
1515
- ignite-2023
1616
---
1717

18-
# Quickstart: Text search by using REST
18+
# Quickstart: Keyword search by using REST
1919

2020
The REST APIs in Azure AI Search provide programmatic access to all of its capabilities, including preview features, and they're an easy way to learn how features work. In this quickstart, learn how to call the [Search REST APIs](/rest/api/searchservice) to create, load, and query a search index in Azure AI Search.
2121

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

2626
- [Visual Studio Code](https://code.visualstudio.com/download) with a [REST client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client).
27+
2728
- [Azure AI Search](search-what-is-azure-search.md). [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. You can use a free service for this quickstart.
2829

2930
## Download files
3031

31-
[Download a REST sample](https://github.com/Azure-Samples/azure-search-rest-samples/tree/main/Quickstart) 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).
32+
[Download a REST sample](https://github.com/Azure-Samples/azure-search-rest-samples/tree/main/Quickstart) from GitHub to send the requests in this quickstart. Instructions can be found at [Downloading files from GitHub](https://docs.github.com/get-started/start-your-journey/downloading-files-from-github).
3233

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

35-
## Copy a search service key and URL
36+
## Get a search service endpoint
37+
38+
You can find the search service endpoint in the Azure portal.
39+
40+
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).
41+
42+
1. On the **Overview** home page, find the URL. An example endpoint might look like `https://mydemo.search.windows.net`.
43+
44+
:::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.":::
45+
46+
You're pasting this endpoint into the `.rest` or `.http` file in a later step.
47+
48+
## Configure access
49+
50+
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.
51+
52+
### Option 1: Use keys
53+
54+
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).
55+
56+
:::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.":::
57+
58+
You're pasting this key into the `.rest` or `.http` file in a later step.
59+
60+
### Option 2: Use roles
61+
62+
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.
63+
64+
In this section, obtain your personal identity token using either the Azure CLI, Azure PowerShell, or the Azure portal.
65+
66+
#### [Azure CLI](#tab/azure-cli)
67+
68+
1. Sign in to Azure CLI.
69+
70+
```azurecli
71+
az login
72+
```
73+
74+
1. Get your personal identity.
3675
37-
REST calls require the search service endpoint and an API key on every request. You can get these values from the Azure portal.
76+
```azurecli
77+
az ad signed-in-user show \
78+
--query id -o tsv
79+
```
80+
81+
#### [Azure PowerShell](#tab/azure-powershell)
82+
83+
1. Sign in with PowerShell.
84+
85+
```azurepowershell
86+
Connect-AzAccount
87+
```
88+
89+
1. Get your personal identity.
90+
91+
```azurepowershell
92+
(Get-AzContext).Account.ExtendedProperties.HomeAccountId.Split('.')[0]
93+
```
94+
95+
#### [Azure portal](#tab/portal)
96+
97+
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.
3898
39-
1. Sign in to the [Azure portal](https://portal.azure.com). Then go to the search service **Overview** page and copy the URL. An example endpoint might look like `https://mydemo.search.windows.net`.
99+
---
40100
41-
1. 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.
101+
You're pasting your personal identity token into the `.rest` or `.http` file in a later step.
42102
43-
:::image type="content" source="media/search-get-started-rest/get-url-key.png" alt-text="Screenshot that shows the URL and API keys in the Azure portal.":::
103+
> [!NOTE]
104+
> 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.
44105
45106
## Set up Visual Studio Code
46107
@@ -54,7 +115,7 @@ If you're not familiar with the REST client for Visual Studio Code, this section
54115
55116
1. Open or create a new file named with either a `.rest` or `.http` file extension.
56117
57-
1. Paste in the following example. Replace the base URL and API key with the values you copied earlier.
118+
1. Paste in the following example if you're using API keys. Replace the `@baseUrl` and `@apiKey` placeholders with the values you copied earlier.
58119
59120
```http
60121
@baseUrl = PUT-YOUR-SEARCH-SERVICE-ENDPOINT-HERE
@@ -66,6 +127,18 @@ If you're not familiar with the REST client for Visual Studio Code, this section
66127
api-key: {{apiKey}}
67128
```
68129
130+
1. Or, paste in this example if your using roles. Replace the `@baseUrl` and `@token` placeholders with the values you copied earlier.
131+
132+
```http
133+
@baseUrl = PUT-YOUR-SEARCH-SERVICE-ENDPOINT-HERE
134+
@token = PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HERE
135+
136+
### List existing indexes by name
137+
GET {{baseUrl}}/indexes?api-version=2023-11-01&$select=name HTTP/1.1
138+
Content-Type: application/json
139+
Authorization: Bearer {{token}}
140+
```
141+
69142
1. Select **Send request**. A response should appear in an adjacent pane. If you have existing indexes, they're listed. Otherwise, the list is empty. If the HTTP code is `200 OK`, you're ready for the next steps.
70143
71144
:::image type="content" source="media/search-get-started-rest/rest-client-request-setup.png" lightbox="media/search-get-started-rest/rest-client-request-setup.png" alt-text="Screenshot that shows a REST client configured for a search service request.":::

0 commit comments

Comments
 (0)