Skip to content

Commit 9a82177

Browse files
committed
CMK doc updates for setting encryption param in CLI
1 parent 4df86bd commit 9a82177

File tree

1 file changed

+84
-13
lines changed

1 file changed

+84
-13
lines changed

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

Lines changed: 84 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ Azure policies help to enforce organizational standards and to assess compliance
325325
326326
### Assign a policy
327327
328-
1. Navigate to a built-in policy and then select **Assign**.
328+
1. In the Azure portal, navigate to a built-in policy and then select **Assign**.
329329
330330
+ [AuditIfExists](https://portal.azure.com/#view/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2F76a56461-9dc0-40f0-82f5-2453283afa2f)
331331
@@ -339,21 +339,92 @@ Azure policies help to enforce organizational standards and to assess compliance
339339
340340
### Enable CMK policy enforcement
341341
342-
+ For new search services, create them with [SearchEncryptionWithCmk](/rest/api/searchmanagement/services/create-or-update?view=rest-searchmanagement-2023-11-01&tabs=HTTP#searchencryptionwithcmk&preserve-view=true) set to `Enabled`. Neither the Azure portal nor the command line tools (the Azure CLI and Azure PowerShell) provide this property, but you can use [Management REST API](/rest/api/searchmanagement/services/create-or-update) to provision a search service with a CMK policy definition.
342+
A policy that's assigned to a resource group in your subscription is effective immediately. Audit policies flag non-compliant resources, but Deny policies prevent the creation and update of non-compliant search services. This section explains how to create a compliant search service or update a service to make it compliant. To bring objects into compliance, start at [step one](#step-1-create-an-encryption-key) of this article.
343343
344-
+ For existing search services, patch them using [Services - Update API](/rest/api/searchmanagement/services/update).
344+
#### Create a compliant search service
345345
346-
```http
347-
PATCH https://management.azure.com/subscriptions/<your-subscription-Id>/resourceGroups/<your-resource-group-name>/providers/Microsoft.Search/searchServices/<your-search-service-name>?api-version=2023-11-01
348-
349-
{
350-
"properties": {
351-
"encryptionWithCmk": {
352-
"enforcement": "Enabled"
353-
}
346+
For new search services, create them with [SearchEncryptionWithCmk](/rest/api/searchmanagement/services/create-or-update?view=rest-searchmanagement-2023-11-01&tabs=HTTP#searchencryptionwithcmk&preserve-view=true) set to `Enabled`.
347+
348+
Neither the Azure portal nor the command line tools (the Azure CLI and Azure PowerShell) provide this property natively, but you can use [Management REST API](/rest/api/searchmanagement/services/create-or-update) to provision a search service with a CMK policy definition. You can also use the Azure CLI `az resource create` or `update` command to set properties as name-value pairs.
349+
350+
### [**Azure CLI**](#tab/azure-cli-create)
351+
352+
1. Create your search service using the examples in [Manage your Azure AI Search service with the Azure CLI](search-manage-azure-cli.md).
353+
354+
1. Patch your service using the update command, substituting valid values for an existing search service and resource group.
355+
356+
```azurecli
357+
az resource update --name SEARCH-SERVICE-PLACEHOLDER --resource-group RESOURCE-GROUP-PLACEHOLDER --resource-type searchServices --namespace Microsoft.Search --set properties.encryptionWithCmk.enforcement=Enabled
358+
```
359+
360+
### [**Management REST API**](#tab/mgmt-rest-create)
361+
362+
This example is from [Manage your Azure AI Search service with REST APIs](search-manage-rest.md), modified to include the [SearchEncryptionWithCmk](/rest/api/searchmanagement/services/create-or-update?view=rest-searchmanagement-2023-11-01&tabs=HTTP#searchencryptionwithcmk&preserve-view=true) property.
363+
364+
```rest
365+
### Create a search service (provide an existing resource group)
366+
@resource-group = my-rg
367+
@search-service-name = my-search
368+
PUT https://management.azure.com/subscriptions/{{subscriptionId}}/resourceGroups/{{resource-group}}/providers/Microsoft.Search/searchServices/{{search-service-name}}?api-version=2023-11-01 HTTP/1.1
369+
Content-type: application/json
370+
Authorization: Bearer {{token}}
371+
372+
{
373+
"location": "North Central US",
374+
"sku": {
375+
"name": "basic"
376+
},
377+
"properties": {
378+
"replicaCount": 1,
379+
"partitionCount": 1,
380+
"hostingMode": "default",
381+
"encryptionWithCmk": {
382+
"enforcement": "Enabled"
383+
}
354384
}
355-
}
356-
```
385+
}
386+
```
387+
388+
---
389+
390+
#### Update an existing search service
391+
392+
For existing search services that are now non-compliant, patch them using [Services - Update API](/rest/api/searchmanagement/services/update). Patching the services restores the ability to update search service properties.
393+
394+
### [**Azure CLI**](#tab/azure-cli-update)
395+
396+
Run the following command, substituting valid values for the search service and resource group.
397+
398+
```azurecli
399+
az resource update --name SEARCH-SERVICE-PLACEHOLDER --resource-group RESOURCE-GROUP-PLACEHOLDER --resource-type searchServices --namespace Microsoft.Search --set properties.encryptionWithCmk.enforcement=Enabled
400+
```
401+
402+
The response should include the following statement:
403+
404+
```bash
405+
"encryptionWithCmk": {
406+
"encryptionComplianceStatus": "NonCompliant",
407+
"enforcement": "Enabled"
408+
}
409+
...
410+
```
411+
412+
"Non-compliant" means the search service has existing objects that aren't CMK encrypted. To achieve compliance, recreate each object, specifying an encryption key.
413+
414+
### [**Management REST API**](#tab/mgmt-rest-update)
415+
416+
```http
417+
PATCH https://management.azure.com/subscriptions/<your-subscription-Id>/resourceGroups/<your-resource-group-name>/providers/Microsoft.Search/searchServices/<your-search-service-name>?api-version=2023-11-01
418+
419+
{
420+
"properties": {
421+
"encryptionWithCmk": {
422+
"enforcement": "Enabled"
423+
}
424+
}
425+
}
426+
```
427+
---
357428

358429
## Rotate or update encryption keys
359430

0 commit comments

Comments
 (0)