You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/ai-foundry/openai/azure-government.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ In some cases, models are retired in Azure Governmen ahead of dates in the comme
66
66
67
67
<br>
68
68
69
-
### Deafault Model Versions
69
+
### Default Model Versions
70
70
In some cases, new model versions are designated as default in Azure Governmen ahead of dates in the commercial cloud. General information on model upgrades can be found at [Working with Azure OpenAI models](/azure/ai-foundry/openai/how-to/working-with-models?tabs=powershell&branch=main#model-deployment-upgrade-configuration)
71
71
72
72
The following shows default model differences in Azure Government.
Copy file name to clipboardExpand all lines: articles/search/search-security-api-keys.md
+59-13Lines changed: 59 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,14 +9,14 @@ ms.service: azure-ai-search
9
9
ms.custom:
10
10
- ignite-2023
11
11
ms.topic: how-to
12
-
ms.date: 07/31/2025
12
+
ms.date: 10/22/2025
13
13
ms.update-cycle: 365-days
14
14
#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.
15
15
---
16
16
17
17
# Connect to Azure AI Search using keys
18
18
19
-
Azure AI Search supports both identity-based 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 in a request header, or 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.
19
+
Azure AI Search supports both identity-based 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 in a request header, or as an [environment variable](/azure/ai-services/cognitive-services-environment-variables) or app setting in your project, and then reference the variable on the request.
20
20
21
21
> [!IMPORTANT]
22
22
> 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).
@@ -45,18 +45,21 @@ Visually, there's no distinction between an admin key or query key. Both keys ar
45
45
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/).
46
46
47
47
You can use either an API key or [Azure roles](search-security-rbac.md) for control plane (service) requests. When you use an API key:
48
-
- Admin keys are used for creating, modifying, or deleting objects. Admin keys are also used to GET object definitions and system information.
48
+
49
+
- Admin keys are used for creating, modifying, or deleting objects. Admin keys are also used to GET object definitions and system information, such as [LIST Indexes](/rest/api/searchservice/indexes/list) or [GET Service Statistics](/rest/api/searchservice/get-service-statistics/get-service-statistics).
50
+
49
51
- Query keys are typically distributed to client applications that issue queries.
50
52
51
53
### [**REST API**](#tab/rest-use)
52
54
53
-
**How API keys are used in REST calls**:
54
-
55
-
Set an admin key in the request header. You can't pass admin keys on the URI or in the body of the request. Admin keys are used for create-read-update-delete operation and on requests issued to the search service itself, such as [LIST Indexes](/rest/api/searchservice/indexes/list) or [GET Service Statistics](/rest/api/searchservice/get-service-statistics/get-service-statistics).
55
+
Set an admin key in the request header. You can't pass admin keys on the URI or in the body of the request.
56
56
57
57
Here's an example of admin API key usage on a create index request:
POST {{baseUrl}}/indexes?api-version=2025-09-01 HTTP/1.1
62
65
Content-Type: application/json
@@ -71,7 +74,7 @@ POST {{baseUrl}}/indexes?api-version=2025-09-01 HTTP/1.1
71
74
}
72
75
```
73
76
74
-
Set a query key in a request header for POST, or on the URI for GET. Query keys are used for operations that target the `index/docs` collection: [Search Documents](/rest/api/searchservice/documents/search-get), [Autocomplete](/rest/api/searchservice/documents/autocomplete-get), [Suggest](/rest/api/searchservice/documents/suggest-get), or [GET Document](/rest/api/searchservice/documents/get).
77
+
Set a query key in a request header for POST, or on the URI for GET. Query keys are used for operations that target the `index/docs` collection: [Search Documents](/rest/api/searchservice/documents/search-get), [Autocomplete](/rest/api/searchservice/documents/autocomplete-get), [Suggest](/rest/api/searchservice/documents/suggest-get), or [GET Document](/rest/api/searchservice/documents/get).
75
78
76
79
Here's an example of query API key usage on a Search Documents (GET) request:
77
80
@@ -83,26 +86,69 @@ GET /indexes/my-new-index/docs?search=*&api-version=2025-09-01&api-key={{queryAp
83
86
> [!NOTE]
84
87
> It's considered a poor security practice to pass sensitive data such as an `api-key` in the request URI. For this reason, Azure AI Search only accepts a query key as an `api-key` in the query string. As a general rule, we recommend passing your `api-key` as a request header.
85
88
86
-
### [**PowerShell**](#tab/azure-ps-use)
89
+
### [**Python**](#tab/python-use)
90
+
91
+
It's a best practice to set the API key as an environment variable, but for simplicity, this example shows it as a string. The example uses a query API key for a query operation.
92
+
93
+
```python
94
+
# Import libraries
95
+
from azure.core.credentials import AzureKeyCredential
96
+
from azure.identity import DefaultAzureCredential, AzureAuthorityHosts
97
+
98
+
# Variables for endpoint, keys, index
99
+
search_endpoint: str="https://<Put your search service NAME here>.search.windows.net/"
100
+
credential = AzureKeyCredential("Your search service query key")
Set API keys in the request header using the following syntax:
91
125
92
-
```azurepowershell
126
+
```powershell
93
127
$headers = @{
94
128
'api-key' = '<YOUR-ADMIN-OR-QUERY-API-KEY>'
95
129
'Content-Type' = 'application/json'
96
130
'Accept' = 'application/json' }
97
131
```
98
132
99
-
A script example showing API key usage for various operations can be found at [Quickstart: Create an Azure AI Search index in PowerShell using REST APIs](search-get-started-text.md).
133
+
Use a variable to contain the fully qualified query:
More script examples for other operations can be found at [Quickstart: Create an Azure AI Search index in PowerShell using REST APIs](search-get-started-text.md).
100
146
101
147
### [**Portal**](#tab/portal-use)
102
148
103
-
**How API keys are used in the Azure portal**:
149
+
Recall that key authentication is enabled by default and supports data plane operations such as indexing and queries.
104
150
105
-
Key authentication applies to data plane operations such as indexing and queries. It's enabled by default. However, if you [disable API keys](search-security-enable-roles.md#disable-api-key-authentication) and set up role assignments, the Azure portal uses role assignments instead.
151
+
However, if you [disable API keys](search-security-enable-roles.md#disable-api-key-authentication) and set up role assignments, the Azure portal uses role assignments instead.
0 commit comments