Skip to content

Commit c53cf6e

Browse files
committed
Updated TOC and RBAC quickstart
1 parent 1ef012e commit c53cf6e

File tree

7 files changed

+237
-155
lines changed

7 files changed

+237
-155
lines changed

articles/search/includes/quickstarts/full-text-rest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ To set up your request file:
9393
Authorization: Bearer {{token}}
9494
```
9595
96-
1. Replace the `@baseUrl` and `@token` placeholders with the values you obtained in [Get endpoint and token](#get-endpoint-and-token). Don't include quotation marks.
96+
1. Replace the `@baseUrl` and `@token` placeholders with the values you obtained in [Get endpoint and token](#get-endpoint-and-token).
9797
9898
1. Under `### List existing indexes by name`, select **Send Request**.
9999
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
manager: nitinme
3+
author: haileytap
4+
ms.author: haileytapia
5+
ms.service: azure-ai-search
6+
ms.topic: include
7+
ms.date: 07/08/2025
8+
---
9+
10+
In this quickstart, you use role-based access control (RBAC) and Microsoft Entra ID to connect to Azure AI Search from your local system. You then use Python in Visual Studio Code to interact with your search service.
11+
12+
We recommend keyless connections for granular permissions and identity-based authentication, which eliminate the need for hard-coded API keys in your code. However, if you prefer key-based connections, see [Connect to Azure AI Search using keys](../../search-security-api-keys.md).
13+
14+
<!-- This quickstart is a prerequisite for other quickstarts that use Microsoft Entra ID with role assignments. -->
15+
16+
## Prerequisites
17+
18+
+ An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
19+
20+
+ An [Azure AI Search service](../../search-create-service-portal.md) in any region or tier.
21+
22+
+ The [Azure CLI](/cli/azure/install-azure-cli) for keyless authentication with Microsoft Entra ID.
23+
24+
+ [Visual Studio Code](https://code.visualstudio.com/) with the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) and [Jupyter package](https://jupyter.org/install).
25+
26+
[!INCLUDE [Setup](./search-get-started-rbac-setup.md)]
27+
28+
## Set up authentication
29+
30+
Before you establish a keyless connection to your Azure AI Search service, you must use the Azure CLI to authenticate your identity with Microsoft Entra ID.
31+
32+
To set up authentication:
33+
34+
1. On your local system, open a command-line tool.
35+
36+
1. Sign in to the subscription whose ID you obtained in [Get service information](#get-service-information).
37+
38+
```azurecli
39+
az login
40+
```
41+
42+
## Connect to Azure AI Search
43+
44+
You can use the Python extension and Jupyter package to send requests to your Azure AI Search service. For request authentication, use the `DefaultAzureCredential` class from the Azure Identity library.
45+
46+
To use Python for keyless connections:
47+
48+
1. On your local system, open Visual Studio Code.
49+
50+
1. Create a `.ipynb` file.
51+
52+
1. Create a code cell to install the `azure-identity` and `azure-search-documents` libraries.
53+
54+
```python
55+
pip install azure-identity azure-search-documents
56+
```
57+
58+
1. Create another code cell to authenticate with `DefaultAzureCredential` and connect to your search service.
59+
60+
```python
61+
from azure.identity import DefaultAzureCredential
62+
from azure.search.documents import SearchClient
63+
64+
service_endpoint = "PUT-YOUR-SEARCH-SERVICE-ENDPOINT-HERE"
65+
index_name = "hotels-sample-index"
66+
67+
credential = DefaultAzureCredential()
68+
client = SearchClient(endpoint=service_endpoint, index_name=index_name, credential=credential)
69+
70+
results = client.search("beach access")
71+
for result in results:
72+
print(result)
73+
```
74+
75+
### Troubleshoot 401 errors
76+
77+
+ Revisit [Configure role-based access](#configure-role-based-access). Your search service must have **Role-based access control** or **Both** enabled. Policies at the subscription or resource group level might also override your role assignments.
78+
79+
+ Revisit [Set up authentication](#set-up-authentication). You must sign in to the correct subscription for your search service.
80+
81+
If all else fails, restart your device to remove cached tokens and then repeat the steps in this quickstart, starting with [Set up authentication](#set-up-authentication).
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
manager: nitinme
3+
author: haileytap
4+
ms.author: haileytapia
5+
ms.service: azure-ai-search
6+
ms.topic: include
7+
ms.date: 07/08/2025
8+
---
9+
10+
In this quickstart, you use role-based access control (RBAC) and Microsoft Entra ID to connect to Azure AI Search from your local system. You then use REST in Visual Studio Code to interact with your search service.
11+
12+
We recommend keyless connections for granular permissions and identity-based authentication, which eliminate the need for hard-coded API keys in your code. However, if you prefer key-based connections, see [Connect to Azure AI Search using keys](../../search-security-api-keys.md).
13+
14+
<!-- This quickstart is a prerequisite for other quickstarts that use Microsoft Entra ID with role assignments. -->
15+
16+
## Prerequisites
17+
18+
+ An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
19+
20+
+ An [Azure AI Search service](../../search-create-service-portal.md) in any region or tier.
21+
22+
+ The [Azure CLI](/cli/azure/install-azure-cli) for keyless authentication with Microsoft Entra ID.
23+
24+
+ [Visual Studio Code](https://code.visualstudio.com/) with the [REST Client extension](https://marketplace.visualstudio.com/items?itemName=humao.rest-client).
25+
26+
[!INCLUDE [Setup](./search-get-started-rbac-setup.md)]
27+
28+
## Set up authentication
29+
30+
Before you establish a keyless connection to your Azure AI Search service, you must use the Azure CLI to authenticate your identity and generate a Microsoft Entra ID token. You specify this token in the next section.
31+
32+
To set up authentication:
33+
34+
1. On your local system, open a command-line tool.
35+
36+
1. Sign in to the subscription whose ID you obtained in [Get service information](#get-service-information).
37+
38+
```azurecli
39+
az login
40+
```
41+
42+
1. Generate an access token.
43+
44+
```azurecli
45+
az account get-access-token --scope https://search.azure.com/.default --query accessToken --output tsv
46+
```
47+
48+
1. Make a note of the token.
49+
50+
## Connect to Azure AI Search
51+
52+
You can use the REST Client extension to send requests to Azure AI Search. For request authentication, include an `Authorization` header with the Microsoft Entra ID token you previously generated.
53+
54+
To use REST for keyless connections:
55+
56+
1. On your local system, open Visual Studio Code.
57+
58+
1. Create a `.rest` or `.http` file.
59+
60+
1. Paste the following placeholders into the file.
61+
62+
```http
63+
@baseUrl = PUT-YOUR-SEARCH-SERVICE-ENDPOINT-HERE
64+
@token = PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HERE
65+
```
66+
67+
1. Replace `@baseUrl` with the value you obtained in [Get service information](#get-service-information).
68+
69+
1. Replace `@token` with the value you obtained in [Set up authentication](#set-up-authentication).
70+
71+
1. Make a REST call to authenticate with your token and connect to your search service.
72+
73+
```http
74+
POST https://{{baseUrl}}/indexes/hotels-sample-index/docs/search?api-version=2024-07-01 HTTP/1.1
75+
Content-type: application/json
76+
Authorization: Bearer {{token}}
77+
78+
{
79+
"queryType": "simple",
80+
"search": "beach access",
81+
"filter": "",
82+
"select": "HotelName,Description,Category,Tags",
83+
"count": true
84+
}
85+
```
86+
87+
### Troubleshoot 401 errors
88+
89+
+ Revisit [Configure role-based access](#configure-role-based-access). Your search service must have **Role-based access control** or **Both** enabled. Policies at the subscription or resource group level might also override your role assignments.
90+
91+
+ Revisit [Set up authentication](#set-up-authentication). You must sign in to the correct subscription for your search service.
92+
93+
+ Make sure your endpoint and token variables don't have surrounding quotes or extra spaces.
94+
95+
+ Make sure your token doesn't have the `@` symbol in the request header. For example, if the variable is `@token`, the reference in the request should be `{{token}}`.
96+
97+
If all else fails, restart your device to remove cached tokens and then repeat the steps in this quickstart, starting with [Set up authentication](#set-up-authentication).
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
manager: nitinme
3+
author: haileytap
4+
ms.author: haileytapia
5+
ms.service: azure-ai-search
6+
ms.topic: include
7+
ms.date: 07/08/2025
8+
---
9+
10+
## Configure role-based access
11+
12+
In this section, you enable RBAC on your Azure AI Search service and assign the necessary roles for creating, loading, and querying search objects. For more information about these steps, see [Connect to Azure AI Search using roles](../../search-security-rbac.md).
13+
14+
To configure access:
15+
16+
1. Sign in to the [Azure portal](https://portal.azure.com) and select your search service.
17+
18+
1. From the left pane, select **Settings > Keys**.
19+
20+
1. Select **Role-based access control** or **Both** if you need time to transition clients to RBAC.
21+
22+
1. From the left pane, select **Access control (IAM)**.
23+
24+
1. Select **Add** > **Add role assignment**.
25+
26+
1. Assign the **Search Service Contributor** role to your user account or managed identity.
27+
28+
1. Repeat the role assignment for **Search Index Data Contributor**.
29+
30+
## Get service information
31+
32+
In this section, you retrieve the subscription ID and endpoint of your Azure AI Search service. You use these values for authentication and connection in the following sections.
33+
34+
To get your service information:
35+
36+
1. Sign in to the [Azure portal](https://portal.azure.com) and select your search service.
37+
38+
1. From the left pane, select **Overview**.
39+
40+
1. Make a note of the subscription ID and endpoint.
41+
42+
:::image type="content" source="../../media/search-get-started-rbac/subscription-and-endpoint.png" lightbox="../../media/search-get-started-rbac/subscription-and-endpoint-name.png" alt-text="Screenshot of the subscription ID and endpoint in the Azure portal.":::
156 KB
Loading

0 commit comments

Comments
 (0)