Skip to content

Commit 5aa22af

Browse files
Merge pull request #3338 from HeidiSteen/heidist-feb
[azure search] CMK doc updates for setting encryption param in CLI
2 parents ef9a892 + ad54124 commit 5aa22af

File tree

1 file changed

+87
-13
lines changed

1 file changed

+87
-13
lines changed

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

Lines changed: 87 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -320,17 +320,19 @@ Azure policies help to enforce organizational standards and to assess compliance
320320
321321
| Effect | Effect if enabled|
322322
|--------|------------------|
323-
| [**AuditIfNotExists**](/azure/governance/policy/concepts/effect-audit-if-not-exists) | Checks for compliance: do objects have a customer-managed key defined, and is the content encrypted. This effect applies to existing services with content. It's evaluated each time an object is created or updated, or [per the evaluation schedule](/azure/governance/policy/overview#understand-evaluation-outcomes). [Learn more...](https://portal.azure.com/#view/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2F356da939-f20a-4bb9-86f8-5db445b0e354) |
323+
| [**AuditIfNotExists**](/azure/governance/policy/concepts/effect-audit-if-not-exists) | Checks for policy compliance: do objects have a customer-managed key defined, and is the content encrypted. This effect applies to existing services with content. It's evaluated each time an object is created or updated, or [per the evaluation schedule](/azure/governance/policy/overview#understand-evaluation-outcomes). [Learn more...](https://portal.azure.com/#view/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2F356da939-f20a-4bb9-86f8-5db445b0e354) |
324324
| [**Deny**](/azure/governance/policy/concepts/effect-deny) | Checks for policy enforcement: does the search service have [SearchEncryptionWithCmk](/rest/api/searchmanagement/services/create-or-update?view=rest-searchmanagement-2023-11-01&tabs=HTTP#searchencryptionwithcmk&preserve-view=true) set to `Enabled`. This effect applies to new services only, which must be created with encryption enabled. Existing services remain operational but you can't update them unless you patch the service. None of the tools used for provisioning services expose this property, so be aware that setting the policy limits you to [programmatic set up](#enable-cmk-policy-enforcement).|
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
332332
+ [Deny](https://portal.azure.com/#view/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2Fproviders%2FMicrosoft.Authorization%2FpolicyDefinitions%2F356da939-f20a-4bb9-86f8-5db445b0e354)
333333
334+
Here's an example of the **AuditIfExists** policy in the Azure portal:
335+
334336
:::image type="content" source="media/search-security-manage-encryption-keys/assign-policy.png" alt-text="Screenshot of assigning built-in CMK policy." border="true":::
335337
336338
1. Set [policy scope](/azure/governance/policy/concepts/scope) by selecting the subscription and resource group. Exclude any search services for which the policy shouldn't apply.
@@ -339,22 +341,94 @@ Azure policies help to enforce organizational standards and to assess compliance
339341
340342
### Enable CMK policy enforcement
341343
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.
344+
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.
343345
344-
+ For existing search services, patch them using [Services - Update API](/rest/api/searchmanagement/services/update).
346+
#### Create a compliant search service
345347
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-
}
348+
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`.
349+
350+
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.
351+
352+
### [**Management REST API**](#tab/mgmt-rest-create)
353+
354+
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.
355+
356+
```rest
357+
### Create a search service (provide an existing resource group)
358+
@resource-group = my-rg
359+
@search-service-name = my-search
360+
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
361+
Content-type: application/json
362+
Authorization: Bearer {{token}}
363+
364+
{
365+
"location": "North Central US",
366+
"sku": {
367+
"name": "basic"
368+
},
369+
"properties": {
370+
"replicaCount": 1,
371+
"partitionCount": 1,
372+
"hostingMode": "default",
373+
"encryptionWithCmk": {
374+
"enforcement": "Enabled"
375+
}
354376
}
355-
}
377+
}
378+
```
379+
380+
### [**Azure CLI**](#tab/azure-cli-create)
381+
382+
1. Create your search service using the examples in [Manage your Azure AI Search service with the Azure CLI](search-manage-azure-cli.md).
383+
384+
1. Patch your service using the update command, substituting valid values for an existing search service and resource group.
385+
386+
```azurecli
387+
az resource update --name SEARCH-SERVICE-PLACEHOLDER --resource-group RESOURCE-GROUP-PLACEHOLDER --resource-type searchServices --namespace Microsoft.Search --set properties.encryptionWithCmk.enforcement=Enabled
356388
```
357389

390+
---
391+
392+
#### Update an existing search service
393+
394+
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.
395+
396+
### [**Management REST API**](#tab/mgmt-rest-update)
397+
398+
```http
399+
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
400+
401+
{
402+
"properties": {
403+
"encryptionWithCmk": {
404+
"enforcement": "Enabled"
405+
}
406+
}
407+
}
408+
```
409+
410+
### [**Azure CLI**](#tab/azure-cli-update)
411+
412+
Run the following command, substituting valid values for the search service and resource group.
413+
414+
```azurecli
415+
az resource update --name SEARCH-SERVICE-PLACEHOLDER --resource-group RESOURCE-GROUP-PLACEHOLDER --resource-type searchServices --namespace Microsoft.Search --set properties.encryptionWithCmk.enforcement=Enabled
416+
```
417+
418+
The response should include the following statement:
419+
420+
```bash
421+
"encryptionWithCmk": {
422+
"encryptionComplianceStatus": "NonCompliant",
423+
"enforcement": "Enabled"
424+
}
425+
...
426+
```
427+
428+
"Non-compliant" means the search service has existing objects that aren't CMK encrypted. To achieve compliance, recreate each object, specifying an encryption key.
429+
430+
---
431+
358432
## Rotate or update encryption keys
359433

360434
Use the following instructions to rotate keys or to migrate from Azure Key Vault to the Hardware Security Model (HSM).

0 commit comments

Comments
 (0)