Skip to content

Commit 6e3f583

Browse files
Merge pull request #2342 from eric-urban/eur/azs-auth-keys-308923
AzS: Authenticate with keys refresh
2 parents b550901 + 4f1e0fc commit 6e3f583

File tree

3 files changed

+24
-33
lines changed

3 files changed

+24
-33
lines changed

articles/search/search-security-api-keys.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@
22
title: Connect using API keys
33
titleSuffix: Azure AI Search
44
description: Learn how to use an admin or query API key for inbound access to an Azure AI Search service endpoint.
5-
65
manager: nitinme
76
author: HeidiSteen
87
ms.author: heidist
98
ms.service: azure-ai-search
109
ms.custom:
1110
- ignite-2023
1211
ms.topic: how-to
13-
ms.date: 10/30/2024
12+
ms.date: 1/16/2025
13+
#customer intent: I want to learn how to connect to Azure AI Search using API keys so that I can authenticate inbound requests to my search service.
1414
---
1515

1616
# Connect to Azure AI Search using keys
1717

18-
Azure AI Search offers key-based authentication for connections to your search service. An API key is a unique string composed of 52 randomly generated numbers and letters. In your source code, you can specify it as an [environment variable](/azure/ai-services/cognitive-services-environment-variables) or as an app setting in your project, and then reference the variable on the request. A request made to a search service endpoint is accepted if both the request and the API key are valid.
19-
20-
Key-based authentication is the default.
18+
Azure AI Search supports both keyless and key-based authentication for connections to your search service. An API key is a unique string composed of 52 randomly generated numbers and letters. In your source code, you can specify it as an [environment variable](/azure/ai-services/cognitive-services-environment-variables) or as an app setting in your project, and then reference the variable on the request. A request made to a search service endpoint is accepted if both the request and the API key are valid.
2119

22-
You can replace it with [role-based access](search-security-enable-roles.md), which eliminates the need for hardcoded keys in your codebase.
20+
> [!IMPORTANT]
21+
> When you create a search service, key-based authentication is the default, but it's not the most secure option. We recommend that you replace it with [role-based access](search-security-enable-roles.md).
2322
2423
## Types of API keys
2524

@@ -36,11 +35,11 @@ Visually, there's no distinction between an admin key or query key. Both keys ar
3635

3736
## Use API keys on connections
3837

39-
API keys are used for data plane (content) requests, such as creating or accessing an index or, any other request that's represented in the [Search REST APIs](/rest/api/searchservice/). Upon service creation, an API key is the only authentication mechanism for data plane operations, but you can replace or supplement key authentication with [Azure roles](search-security-rbac.md) if you can't use hard-coded keys in your code.
40-
41-
Admin keys are used for creating, modifying, or deleting objects. Admin keys are also used to GET object definitions and system information.
38+
API keys are used for data plane (content) requests, such as creating or accessing an index or, any other request that's represented in the [Search REST APIs](/rest/api/searchservice/).
4239

43-
Query keys are typically distributed to client applications that issue queries.
40+
You can use either an API key or [Azure roles](search-security-rbac.md) for management plane (service) requests. When you use an API key:
41+
- Admin keys are used for creating, modifying, or deleting objects. Admin keys are also used to GET object definitions and system information.
42+
- Query keys are typically distributed to client applications that issue queries.
4443

4544
### [**REST API**](#tab/rest-use)
4645

@@ -241,11 +240,13 @@ It's not possible to use [customer-managed key encryption](search-security-manag
241240

242241
## Best practices
243242

243+
+ For production workloads, switch to [Microsoft Entra ID and role-based access](keyless-connections.md). Or, if you want to continue using API keys, be sure to always monitor [who has access to your API keys](#secure-api-keys) and [regenerate API keys](#regenerate-admin-keys) on a regular cadence.
244+
244245
+ Only use API keys if data disclosure isn't a risk (for example, when using sample data) and if you're operating behind a firewall. Exposure of API keys is a risk to both data and to unauthorized use of your search service.
245246

246-
+ Always check code, samples, and training material before publishing to make sure you didn't leave valid API keys behind.
247+
+ If you use an API key, store it securely somewhere else, such as in [Azure Key Vault](/azure/key-vault/general/overview). Don't include the API key directly in your code, and never post it publicly.
247248

248-
+ For production workloads, switch to [Microsoft Entra ID and role-based access](keyless-connections.md). Or, if you want to continue using API keys, be sure to always monitor [who has access to your API keys](#secure-api-keys) and [regenerate API keys](#regenerate-admin-keys) on a regular cadence.
249+
+ Always check code, samples, and training material before publishing to make sure you don't inadvertently expose an API key.
249250

250251
## See also
251252

articles/search/search-security-enable-roles.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22
title: Enable role-based access control
33
titleSuffix: Azure AI Search
44
description: Enable or disable role-based access control for token authentication using Microsoft Entra ID on Azure AI Search.
5-
65
manager: nitinme
76
author: HeidiSteen
87
ms.author: heidist
98
ms.service: azure-ai-search
109
ms.topic: how-to
11-
ms.date: 10/30/2024
12-
10+
ms.date: 1/16/2025
11+
#customer intent: As a developer, I want to enable role-based access control for token authentication using Microsoft Entra ID on Azure AI Search so that I can secure my search service.
1312
---
1413

1514
# Enable or disable role-based access control in Azure AI Search
1615

17-
Azure AI Search uses [key-based authentication](search-security-api-keys.md) by default, but it fully supports Microsoft Entra ID authentication and authorization for all control plane and data plane operations through Azure role-based access control (RBAC).
16+
Azure AI Search supports both keyless and [key-based authentication](search-security-api-keys.md) for for all control plane and data plane operations. You can use Microsoft Entra ID authentication and authorization for all control plane and data plane operations through Azure role-based access control (RBAC).
17+
18+
> [!IMPORTANT]
19+
> When you create a search service, key-based authentication is the default, but it's not the most secure option. We recommend that you replace it with role-based access as described in this article.
1820
1921
Before you can assign roles for authorized data plane access to Azure AI Search, you must enable role-based access control on your search service. Roles for service administration (control plane) are built in and can't be enabled or disabled.
2022

@@ -37,18 +39,18 @@ The default failure mode for unauthorized requests is `http401WithBearerChalleng
3739

3840
### [**Azure portal**](#tab/config-svc-portal)
3941

40-
1. Sign in to the [Azure portal](https://portal.azure.com) and open the search service page.
42+
1. Sign in to the [Azure portal](https://portal.azure.com) and navigate to your search service.
4143

4244
1. Select **Settings** and then select **Keys** in the left navigation pane.
4345

4446
:::image type="content" source="media/search-security-rbac/search-security-enable-roles.png" lightbox="media/search-security-rbac/search-security-enable-roles.png" alt-text="Screenshot of the keys page with authentication options." border="true":::
4547

46-
1. Choose **Role-based control** or **Both** if you're currently using keys and need time to transition clients to role-based access control.
48+
1. Choose **Role-based control**. Only choose **Both** if you're currently using keys and need time to transition clients to role-based access control.
4749

4850
| Option | Description |
4951
|--------|--------------|
50-
| API Key | (default). Requires [API keys](search-security-api-keys.md) on the request header for authorization. |
51-
| Role-based access control | Requires membership in a role assignment to complete the task. It also requires an authorization header on the request. |
52+
| API Key (default) | Requires [API keys](search-security-api-keys.md) on the request header for authorization. |
53+
| Role-based access control (recommended) | Requires membership in a role assignment to complete the task. It also requires an authorization header on the request. |
5254
| Both | Requests are valid using either an API key or role-based access control, but if you provide both in the same request, the API key is used. |
5355

5456
1. As an administrator, if you choose a roles-only approach, [assign data plane roles](search-security-rbac.md) to your user account to restore full administrative access over data plane operations in the Azure portal. Roles include Search Service Contributor, Search Index Data Contributor, and Search Index Data Reader. You need the first two roles if you want equivalent access.
@@ -140,7 +142,7 @@ All calls to the Management REST API are authenticated through Microsoft Entra I
140142
141143
It's possible to disable role-based access control for data plane operations and use key-based authentication instead. You might do this as part of a test workflow, for example to rule out permission issues.
142144
143-
Reverse the steps you followed previously to enable role-based access.
145+
To disable role-based access control in the Azure portal:
144146
145147
1. Sign in to the [Azure portal](https://portal.azure.com) and open the search service page.
146148
@@ -221,12 +223,6 @@ To re-enable key authentication, set "disableLocalAuth" to false. The search ser
221223
222224
---
223225
224-
## Effects of role-based access control
225-
226-
+ Role-based access control can increase the latency of some requests. Each unique combination of service resource (index, indexer, skillsets and so forth) and service principal triggers an authorization check. These authorization checks can add up to 200 milliseconds of latency per request.
227-
228-
+ In rare cases where requests originate from a high number of different service principals, all targeting different service resources (indexes, indexers, and so forth), it's possible for the authorization checks to result in throttling. Throttling would only happen if hundreds of unique combinations of search service resource and service principal were used within a second.
229-
230226
## Next steps
231227
232228
> [!div class="nextstepaction"]

articles/search/search-security-rbac.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,6 @@ To enable a Conditional Access policy for Azure AI Search, follow these steps:
606606
> [!IMPORTANT]
607607
> If your search service has a managed identity assigned to it, the specific search service will show up as a cloud app that can be included or excluded as part of the Conditional Access policy. Conditional Access policies can't be enforced on a specific search service. Instead make sure you select the general **Azure AI Search** cloud app.
608608

609-
## Limitations
610-
611-
+ Role-based access control can increase the latency of some requests. Each unique combination of service resource (index, indexer, etc.) and service principal triggers an authorization check. These authorization checks can add up to 200 milliseconds of latency per request.
612-
613-
+ In rare cases where requests originate from a high number of different service principals, all targeting different service resources (indexes, indexers, etc.), it's possible for the authorization checks to result in throttling. Throttling would only happen if hundreds of unique combinations of search service resource and service principal were used within a second.
614-
615609
## Troubleshooting role-based access control issues
616610

617611
When developing applications that use role-based access control for authentication, some common issues might occur:

0 commit comments

Comments
 (0)