Skip to content

Commit 4fb6fe2

Browse files
committed
revised H2s and removed unnecessary step
1 parent e63b2e7 commit 4fb6fe2

File tree

1 file changed

+43
-61
lines changed

1 file changed

+43
-61
lines changed

articles/search/search-security-manage-encryption-keys.md

Lines changed: 43 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Azure AI Search automatically encrypts data at rest with [service-managed keys](
2020

2121
This article walks you through the steps of setting up customer-managed key (CMK) or "bring-your-own-key" (BYOK) encryption. Here are some points to keep in mind:
2222

23-
+ CMK encryption is enacted on individual objects. If you require CMK across your search service, [set an enforcement policy](#encryption-enforcement-policy).
23+
+ CMK encryption is enacted on individual objects. If you require CMK across your search service, [set an enforcement policy](#set-up-a-policy-to-enforce-cmk-compliance).
2424

2525
+ CMK encryption depends on [Azure Key Vault](/azure/key-vault/general/overview). You can create your own encryption keys and store them in a key vault, or you can use Azure Key Vault APIs to generate encryption keys. Azure Key Vault must be in the same subscription as Azure AI Search, but it can be in a different tenant. Using the same tenant makes it easier to retrieve your managed key by connecting through a system or user-managed identity. This behavior requires both services to share the same tenant. For more information about creating a tenant, see [Set up a new tenant](/azure/active-directory/develop/quickstart-create-new-tenant).
2626

@@ -65,7 +65,7 @@ Although double encryption is now available in all regions, support was rolled o
6565

6666
+ [Azure Key Vault](/azure/key-vault/general/overview) in the same subscription as Azure AI Search. You can [create a key vault using the Azure portal](/azure/key-vault/general/quick-create-portal), [Azure CLI](/azure/key-vault/general/quick-create-cli), or [Azure PowerShell](/azure/key-vault/general/quick-create-powershell). The key vault must have **soft-delete** and **purge protection** enabled.
6767

68-
+ A search client that can create an encrypted object. Into this code, you reference a key vault key and application registration information. This code could be a working app, or prototype code such as the [C# code sample DotNetHowToEncryptionUsingCMK](https://github.com/Azure-Samples/search-dotnet-getting-started/tree/master/DotNetHowToEncryptionUsingCMK).
68+
+ A search client that can create an encrypted object. Into this code, you reference a key vault key and application registration information. This code could be a working app, or prototype code such as the [Python example](#python-example-of-an-encryption-key-configuration) in this article.
6969

7070
To add CMK support, create an object using the [REST client](search-get-started-rest.md), [Azure PowerShell](search-get-started-powershell.md), or an Azure SDK (Python, .NET, Java, JavaScript).
7171

@@ -81,63 +81,13 @@ If you're new to Azure Key Vault, review this quickstart to learn about basic ta
8181

8282
+ Use as many key vaults as you need. Managed keys can be in different key vaults. A search service can have multiple encrypted objects, each one encrypted with a different customer-managed encryption key, stored in different key vaults.
8383

84-
+ [Enable logging](/azure/key-vault/general/logging) on Key Vault so that you can monitor key usage.
84+
+ [Enable purge protection](/azure/key-vault/general/soft-delete-overview#purge-protection) and [soft-delete](/azure/key-vault/general/soft-delete-overview). Due to the nature of encryption with customer-managed keys, no one can retrieve your data if your Azure Key Vault key is deleted. To prevent data loss caused by accidental Key Vault key deletions, soft-delete and purge protection must be enabled on the key vault. Soft-delete is enabled by default, so you'll only encounter issues if you purposely disable it. Purge protection isn't enabled by default, but it's required for customer-managed key encryption in Azure AI Search.
8585

86-
+ Remember to follow strict procedures during routine rotation of key vault keys and application secrets and registration. Always update all [encrypted content](search-security-get-encryption-keys.md) to use new secrets and keys before deleting the old ones. If you miss this step, your content can't be decrypted.
86+
+ [Enable logging](/azure/key-vault/general/logging) on the key vault so that you can monitor key usage.
8787

88-
## 1 - Enable purge protection
88+
+ [Enable autorotation of keys](/azure/key-vault/keys/how-to-configure-key-rotation) or follow strict procedures during routine rotation of key vault keys and application secrets and registration. Always update all [encrypted content](search-security-get-encryption-keys.md) to use new secrets and keys before deleting the old ones. If you miss this step, your content can't be decrypted.
8989

90-
As a first step, make sure [soft-delete](/azure/key-vault/general/soft-delete-overview) and [purge protection](/azure/key-vault/general/soft-delete-overview#purge-protection) are enabled on the key vault. Due to the nature of encryption with customer-managed keys, no one can retrieve your data if your Azure Key Vault key is deleted.
91-
92-
To prevent data loss caused by accidental Key Vault key deletions, soft-delete and purge protection must be enabled on the key vault. Soft-delete is enabled by default, so you'll only encounter issues if you purposely disable it. Purge protection isn't enabled by default, but it's required for customer-managed key encryption in Azure AI Search.
93-
94-
You can set both properties using the portal, PowerShell, or Azure CLI commands.
95-
96-
### [**Azure portal**](#tab/portal-pp)
97-
98-
1. Sign in to the [Azure portal](https://portal.azure.com) and open your key vault overview page.
99-
100-
1. On the **Overview** page under **Essentials**, enable **Soft-delete** and **Purge protection**.
101-
102-
### [**Using PowerShell**](#tab/ps-pp)
103-
104-
1. Run `Connect-AzAccount` to set up your Azure credentials.
105-
106-
1. Run the following command to connect to your key vault, replacing `<vault_name>` with a valid name:
107-
108-
```powershell
109-
$resource = Get-AzResource -ResourceId (Get-AzKeyVault -VaultName "<vault_name>").ResourceId
110-
```
111-
112-
1. Azure Key Vault is created with soft-delete enabled. If it's disabled on your vault, run the following command:
113-
114-
```powershell
115-
$resource.Properties | Add-Member -MemberType NoteProperty -Name "enableSoftDelete" -Value 'true'
116-
```
117-
118-
1. Enable purge protection:
119-
120-
```powershell
121-
$resource.Properties | Add-Member -MemberType NoteProperty -Name "enablePurgeProtection" -Value 'true'
122-
```
123-
124-
1. Save your updates:
125-
126-
```powershell
127-
Set-AzResource -resourceid $resource.ResourceId -Properties $resource.Properties
128-
```
129-
130-
### [**Using Azure CLI**](#tab/cli-pp)
131-
132-
+ If you have an [installation of Azure CLI](/cli/azure/install-azure-cli), you can run the following command to enable the required properties.
133-
134-
```azurecli-interactive
135-
az keyvault update -n <vault_name> -g <resource_group> --enable-soft-delete --enable-purge-protection
136-
```
137-
138-
---
139-
140-
## 2 - Create a key in Key Vault
90+
## Step 1: Create a key in Key Vault
14191

14292
Skip key generation if you already have a key in Azure Key Vault that you want to use, but collect the key identifier. You need this information when creating an encrypted object.
14393

@@ -161,7 +111,7 @@ Azure AI Search encryption supports RSA keys of sizes 2048, 3072 and 4096. For m
161111

162112
:::image type="content" source="media/search-manage-encryption-keys/cmk-key-identifier.png" alt-text="Create a new key vault key" border="true":::
163113

164-
## 3 - Create a security principal
114+
## Step 2: Create a security principal
165115

166116
You have several options for setting up Azure AI Search access to the encryption key at run time. The simplest approach is to retrieve the key using the managed identity of your search service. You can use either a system or user-managed identity. Doing so allows you to omit the steps for application registration and application secrets. Alternatively, you can create and register a Microsoft Entra application and have the search service provides the application ID on requests.
167117

@@ -262,7 +212,7 @@ Enable the system assigned managed identity for your search service.
262212
263213
---
264214
265-
## 4 - Grant permissions
215+
## Step 3: Grant permissions
266216
267217
Azure Key Vault supports authorization using role-based access controls. We recommend this approach over key vault access policies. For more information, see [Provide access to Key Vault keys, certificates, and secrets using Azure roles](/azure/key-vault/general/rbac-guide).
268218
@@ -302,9 +252,9 @@ Access permissions could be revoked at any given time. Once revoked, any search
302252
303253
<a name="encrypt-content"></a>
304254
305-
## 5 - Encrypt content
255+
## Step 4: Encrypt content
306256
307-
Encryption keys are added when you create an object. To add a customer-managed key on an index, synonym map, indexer, data source, or skillset, use the [Search REST API](/rest/api/searchservice/) or an Azure SDK to create an object that has encryption enabled. The portal doesn't allow encryption properties on object creation.
257+
Encryption keys are added when you create an object. To add a customer-managed key on an index, synonym map, indexer, data source, or skillset, use the [Search REST API](/rest/api/searchservice/) or an Azure SDK to create an object that has encryption enabled. To add encryption using the Azure SDK, see the [Python example](#python-example-of-an-encryption-key-configuration) in this article.
308258
309259
1. Call the Create APIs to specify the **encryptionKey** property:
310260
@@ -515,8 +465,40 @@ except Exception as ex:
515465
index_client = SearchClient(endpoint=AZURE_SEARCH_SERVICE, credential=credential)
516466
```
517467

518-
Since encrypted content is decrypted prior to data refresh or queries, you won't see visual evidence of encryption. To verify encryption is working, check the resource logs.
468+
Run a query to confirm the index is operational.
469+
470+
```python
471+
from azure.search.documents import SearchClient
472+
473+
query = "historic"
519474

475+
search_client = SearchClient(endpoint=AZURE_SEARCH_SERVICE, credential=credential, index_name=index_name)
476+
477+
results = search_client.search(
478+
query_type='simple',
479+
search_text=query,
480+
select=["Id", "Description"],
481+
include_total_count=True
482+
)
483+
484+
for result in results:
485+
print(f"Score: {result['@search.score']}")
486+
print(f"Id: {result['Id']}")
487+
print(f"Description: {result['Description']}")
488+
```
489+
490+
Output from the query should produce results similar to the following example.
491+
492+
```
493+
Score: 0.6130029
494+
Id: 4
495+
Description: The hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 1800 palace.
496+
Score: 0.26286605
497+
Id: 1
498+
Description: The hotel is ideally located on the main commercial artery of the city in the heart of New York. A few minutes away is Time's Square and the historic centre of the city, as well as other places of interest that make New York one of America's most attractive and cosmopolitan cities.
499+
```
500+
501+
Since encrypted content is decrypted prior to data refresh or queries, you won't see visual evidence of encryption. To verify encryption is working, check the resource logs.
520502

521503
## Next steps
522504

0 commit comments

Comments
 (0)