Skip to content

Commit ef1aecb

Browse files
committed
Updated RBAC quickstart
1 parent 350f2fd commit ef1aecb

File tree

7 files changed

+76
-58
lines changed

7 files changed

+76
-58
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ To set up your request file:
8989
@token = PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HERE
9090
9191
### List existing indexes by name
92-
GET {{baseUrl}}/indexes?api-version=2024-07-01
92+
GET {{baseUrl}}/indexes?api-version=2024-07-01 HTTP/1.1
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).
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.
9797
9898
1. Under `### List existing indexes by name`, select **Send Request**.
9999

articles/search/includes/quickstarts/search-get-started-rbac-python.md

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ author: haileytap
44
ms.author: haileytapia
55
ms.service: azure-ai-search
66
ms.topic: include
7-
ms.date: 07/08/2025
7+
ms.date: 07/09/2025
88
---
99

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.
10+
In this quickstart, you use role-based access control (RBAC) and Microsoft Entra ID to establish a keyless connection to your Azure AI Search service. You then use Python in Visual Studio Code to interact with the service.
1111

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).
12+
Keyless connections provide enhanced security through granular permissions and identity-based authentication. We don't recommend hard-coded API keys, but if you prefer them, see [Connect to Azure AI Search using keys](../../search-security-api-keys.md).
1313

1414
<!-- This quickstart is a prerequisite for other quickstarts that use Microsoft Entra ID with role assignments. -->
1515

@@ -25,25 +25,30 @@ We recommend keyless connections for granular permissions and identity-based aut
2525

2626
[!INCLUDE [Setup](./search-get-started-rbac-setup.md)]
2727

28-
## Set up authentication
28+
## Sign in to Azure
2929

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.
30+
Before you connect to your Azure AI Search service, use the Azure CLI to sign in to the subscription that contains the service. This step establishes your Microsoft Entra identity, which `DefaultAzureCredential` uses to authenticate requests in the next section.
3131

32-
To set up authentication:
32+
To sign in:
3333

3434
1. On your local system, open a command-line tool.
3535

36-
1. Sign in to the subscription whose ID you obtained in [Get service information](#get-service-information).
36+
1. Sign in to Azure.
3737

3838
```azurecli
3939
az login
4040
```
4141

42+
1. (Conditional) If you have multiple subscriptions, select the one whose ID you obtained in [Get service information](#get-service-information).
43+
4244
## Connect to Azure AI Search
4345

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.
46+
> [!NOTE]
47+
> This section illustrates the basic Python pattern for keyless connections. For comprehensive guidance, see a specific quickstart or tutorial, such as [Quickstart: Run agentic retrieval in Azure AI Search](../../search-quickstart-agentic-retrieval.md).
48+
49+
You can use Python notebooks in Visual Studio Code to send requests to your Azure AI Search service. For request authentication, use the `DefaultAzureCredential` class from the Azure Identity library.
4550

46-
To use Python for keyless connections:
51+
To connect using Python:
4752

4853
1. On your local system, open Visual Studio Code.
4954

@@ -55,27 +60,38 @@ To use Python for keyless connections:
5560
pip install azure-identity azure-search-documents
5661
```
5762

58-
1. Create another code cell to authenticate with `DefaultAzureCredential` and connect to your search service.
63+
1. Create another code cell to authenticate and connect to your search service.
5964

6065
```python
6166
from azure.identity import DefaultAzureCredential
62-
from azure.search.documents import SearchClient
67+
from azure.search.documents.indexes import SearchIndexClient
6368

6469
service_endpoint = "PUT-YOUR-SEARCH-SERVICE-ENDPOINT-HERE"
65-
index_name = "hotels-sample-index"
66-
6770
credential = DefaultAzureCredential()
68-
client = SearchClient(endpoint=service_endpoint, index_name=index_name, credential=credential)
71+
client = SearchIndexClient(endpoint=service_endpoint, credential=credential)
6972

70-
results = client.search("beach access")
71-
for result in results:
72-
print(result)
73+
# List existing indexes
74+
indexes = client.list_indexes()
75+
76+
for index in indexes:
77+
index_dict = index.as_dict()
78+
print(json.dumps(index_dict, indent=2))
7379
```
7480

81+
1. Set `service_endpoint` to the value you obtained in [Get service information](#get-service-information).
82+
83+
1. Select **Run All** to run both code cells.
84+
85+
The output should list existing indexes on your search service, indicating a successful connection.
86+
7587
### Troubleshoot 401 errors
7688

89+
If you encounter a 401 error, follow these troubleshooting steps:
90+
7791
+ 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.
7892

79-
+ Revisit [Set up authentication](#set-up-authentication). You must sign in to the correct subscription for your search service.
93+
+ Revisit [Sign in to Azure](#sign-in-to-azure). You must sign in to the subscription that contains your search service.
94+
95+
+ Make sure your endpoint variable has surrounding quotes.
8096

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).
97+
+ If all else fails, restart your device to remove cached tokens and then repeat the steps in this quickstart, starting with [Sign in to Azure](#sign-in-to-azure).

articles/search/includes/quickstarts/search-get-started-rbac-rest.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ author: haileytap
44
ms.author: haileytapia
55
ms.service: azure-ai-search
66
ms.topic: include
7-
ms.date: 07/08/2025
7+
ms.date: 07/09/2025
88
---
99

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.
10+
In this quickstart, you use role-based access control (RBAC) and Microsoft Entra ID to establish a keyless connection to your Azure AI Search service. You then use REST in Visual Studio Code to interact with the service.
1111

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).
12+
Keyless connections provide enhanced security through granular permissions and identity-based authentication. We don't recommend hard-coded API keys, but if you prefer them, see [Connect to Azure AI Search using keys](../../search-security-api-keys.md).
1313

1414
<!-- This quickstart is a prerequisite for other quickstarts that use Microsoft Entra ID with role assignments. -->
1515

@@ -25,73 +25,73 @@ We recommend keyless connections for granular permissions and identity-based aut
2525

2626
[!INCLUDE [Setup](./search-get-started-rbac-setup.md)]
2727

28-
## Set up authentication
28+
## Get token
2929

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.
30+
Before you connect to your Azure AI Search service, use the Azure CLI to sign in to the subscription that contains the service and generate a Microsoft Entra ID token. You use this token to authenticate requests in the next section.
3131

32-
To set up authentication:
32+
To get your token:
3333

3434
1. On your local system, open a command-line tool.
3535

36-
1. Sign in to the subscription whose ID you obtained in [Get service information](#get-service-information).
36+
1. Sign in to Azure.
3737

3838
```azurecli
3939
az login
4040
```
4141

42+
1. (Conditional) If you have multiple subscriptions, select the one whose ID you obtained in [Get service information](#get-service-information).
43+
4244
1. Generate an access token.
4345

44-
```azurecli
45-
az account get-access-token --scope https://search.azure.com/.default --query accessToken --output tsv
46-
```
46+
```azurecli
47+
az account get-access-token --scope https://search.azure.com/.default --query accessToken --output tsv
48+
```
4749

48-
1. Make a note of the token.
50+
1. Make a note of the token output.
4951

5052
## Connect to Azure AI Search
5153

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.
54+
> [!NOTE]
55+
> This section illustrates the basic REST pattern for keyless connections. For comprehensive guidance, see a specific quickstart or tutorial, such as [Quickstart: Run agentic retrieval in Azure AI Search](../../search-quickstart-agentic-retrieval.md).
5356
54-
To use REST for keyless connections:
57+
You can use the REST Client extension in Visual Studio Code to send requests to your Azure AI Search service. For request authentication, include an `Authorization` header with the Microsoft Entra ID token you previously generated.
58+
59+
To connect using REST:
5560

5661
1. On your local system, open Visual Studio Code.
5762

5863
1. Create a `.rest` or `.http` file.
5964

60-
1. Paste the following placeholders into the file.
65+
1. Paste the following placeholders and request into the file.
6166

6267
```http
6368
@baseUrl = PUT-YOUR-SEARCH-SERVICE-ENDPOINT-HERE
6469
@token = PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HERE
70+
71+
### List existing indexes
72+
GET {{baseUrl}}/indexes?api-version=2024-07-01 HTTP/1.1
73+
Content-Type: application/json
74+
Authorization: Bearer {{token}}
6575
```
6676

6777
1. Replace `@baseUrl` with the value you obtained in [Get service information](#get-service-information).
6878

69-
1. Replace `@token` with the value you obtained in [Set up authentication](#set-up-authentication).
79+
1. Replace `@token` with the value you obtained in [Get token](#get-token).
7080

71-
1. Make a REST call to authenticate with your token and connect to your search service.
81+
1. Under `### List existing indexes`, select **Send Request**.
7282

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-
```
83+
You should receive an `HTTP/1.1 200 OK` response, indicating a successful connection to your search service.
8684

8785
### Troubleshoot 401 errors
8886

87+
If you encounter a 401 error, follow these troubleshooting steps:
88+
8989
+ 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.
9090

91-
+ Revisit [Set up authentication](#set-up-authentication). You must sign in to the correct subscription for your search service.
91+
+ Revisit [Get token](#get-token). You must sign in to the subscription that contains your search service.
9292

9393
+ Make sure your endpoint and token variables don't have surrounding quotes or extra spaces.
9494

9595
+ 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}}`.
9696

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).
97+
+ If all else fails, restart your device to remove cached tokens and then repeat the steps in this quickstart, starting with [Get token](#get-token).

articles/search/includes/quickstarts/search-get-started-rbac-setup.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@ To configure access:
1919

2020
1. Select **Role-based access control** or **Both** if you need time to transition clients to RBAC.
2121

22+
:::image type="content" source="../../media/search-get-started-rbac/access-control-options.png" lightbox="../../media/search-get-started-rbac/access-control-options.png" alt-text="Screenshot of the access control options in the Azure portal.":::
23+
2224
1. From the left pane, select **Access control (IAM)**.
2325

2426
1. Select **Add** > **Add role assignment**.
2527

28+
:::image type="content" source="../../media/search-get-started-rbac/add-role-assignment.png" lightbox="../../media/search-get-started-rbac/add-role-assignment.png" alt-text="Screenshot of the dropdown menu for adding a role assignment in the Azure portal.":::
29+
2630
1. Assign the **Search Service Contributor** role to your user account or managed identity.
2731

2832
1. Repeat the role assignment for **Search Index Data Contributor**.
2933

3034
## Get service information
3135

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.
36+
In this section, you retrieve the subscription ID and endpoint of your Azure AI Search service. If you have one subscription, skip the subscription ID and only retrieve the endpoint. You use these values in the remaining sections of this quickstart.
3337

3438
To get your service information:
3539

144 KB
Loading
147 KB
Loading

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ zone_pivot_groups: search-get-started-rbac
2626

2727
## Related content
2828

29-
+ [Configure a system- or user-assigned managed identity](search-howto-managed-identities-data-sources.md) for your search service.
30-
31-
+ [Use role assignments](keyless-connections.md) to authorize access to other Azure resources.
32-
33-
+ [Set inbound rules](service-configure-firewall.md) to accept or reject Azure AI Search requests based on IP address.
29+
+ [Configure a managed identity in Azure AI Search](search-howto-managed-identities-data-sources.md)
30+
+ [Connect your app to Azure AI Search using identities](keyless-connections.md)
31+
+ [Configure network access and firewall rules for Azure AI Search](service-configure-firewall.md)

0 commit comments

Comments
 (0)