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
This article reviews two flows for encrypting data with a customer-managed key:
36
+
1. Encrypt data with a customer-managed key stored in a standard Azure Key Vault
37
+
2. Encrypt data with a customer-managed key stored in a network-proteted Azure Key Vault with [Trusted Services](../key-vault/general/network-security.md) enabled.
38
+
39
+
## Encrypt data with a customer-managed key in a network-proected Azure Key Vault with Trusted Services enabled
36
40
37
41
### Create Service Principal for ACI
38
42
@@ -239,6 +243,212 @@ az deployment group create --resource-group myResourceGroup --template-file depl
239
243
240
244
Within a few seconds, you should receive an initial response from Azure. Once the deployment completes, all data related to it persisted by the ACI service will be encrypted with the key you provided.
241
245
246
+
## Encrypt data with a customer-managed key in a standard Azure Key Vault
247
+
248
+
### Create Service Principal for ACI
249
+
250
+
The first step is to ensure that your [Azure tenant](../active-directory/develop/quickstart-create-new-tenant.md) has a service principal assigned for granting permissions to the Azure Container Instances service.
251
+
252
+
> [!IMPORTANT]
253
+
> In order to run the following command and create a service principal successfully, confirm that you have permissions to create service principals in your tenant.
254
+
>
255
+
256
+
The following CLI command will set up the ACI SP in your Azure environment:
257
+
258
+
```azurecli-interactive
259
+
az ad sp create --id 6bb8e274-af5d-4df2-98a3-4fd78b4cafd9
260
+
```
261
+
262
+
The output from running this command should show you a service principal that has been set up with "displayName": "Azure Container Instance Service."
263
+
264
+
In case you are unable to successfully create the service principal:
265
+
* confirm that you have permissions to do so in your tenant
266
+
* check to see if a service principal already exists in your tenant for deploying to ACI. You can do that by running `az ad sp show --id 6bb8e274-af5d-4df2-98a3-4fd78b4cafd9` and use that service principal instead
267
+
268
+
### Create a Key Vault resource
269
+
270
+
Create an Azure Key Vault using [Azure portal](../key-vault/general/quick-create-portal.md), [Azure CLI](../key-vault/general/quick-create-cli.md), or [Azure PowerShell](../key-vault/general/quick-create-powershell.md).
271
+
272
+
For the properties of your key vault, use the following guidelines:
273
+
* Name: A unique name is required.
274
+
* Subscription: Choose a subscription.
275
+
* Under Resource Group, either choose an existing resource group, or create new and enter a resource group name.
276
+
* In the Location pull-down menu, choose a location.
277
+
* You can leave the other options to their defaults or pick based on additional requirements.
278
+
279
+
> [!IMPORTANT]
280
+
> When using customer-managed keys to encrypt an ACI deployment template, it is recommended that the following two properties be set on the key vault, Soft Delete and Do Not Purge. These properties are not enabled by default, but can be enabled using either PowerShell or Azure CLI on a new or existing key vault.
281
+
282
+
### Generate a new key
283
+
284
+
Once your key vault is created, navigate to the resource in Azure portal. On the left navigation menu of the resource blade, under Settings, click **Keys**. On the view for "Keys," click "Generate/Import" to generate a new key. Use any unique Name for this key, and any other preferences based on your requirements.
285
+
286
+

287
+
288
+
### Set access policy
289
+
290
+
Create a new access policy for allowing the ACI service to access your Key.
291
+
292
+
* Once your key has been generated, back in your key vault resource blade, under Settings, click **Access Policies**.
293
+
* On the "Access Policies" page for your key vault, click **Add Access Policy**.
294
+
* Set the *Key Permissions* to include **Get** and **Unwrap Key**
> Encrypting deployment data with a customer-managed key is available in the latest API version (2019-12-01) that is currently rolling out. Specify this API version in your deployment template. If you have any issues with this, please reach out to Azure Support.
307
+
308
+
Once the key vault key and access policy are set up, add the following properties to your ACI deployment template. Learn more about deploying ACI resources with a template in the [Tutorial: Deploy a multi-container group using a Resource Manager template](./container-instances-multi-container-group.md).
309
+
* Under `resources`, set `apiVersion` to `2019-12-01`.
310
+
* Under the container group properties section of the deployment template, add an `encryptionProperties`, which contains the following values:
311
+
*`vaultBaseUrl`: the DNS Name of your key vault, can be found on the overview blade of the key vault resource in Portal
312
+
*`keyName`: the name of the key generated earlier
313
+
*`keyVersion`: the current version of the key. This can be found by clicking into the key itself (under "Keys" in the Settings section of your key vault resource)
314
+
* Under the container group properties, add a `sku` property with value `Standard`. The `sku` property is required in API version 2019-12-01.
315
+
316
+
The following template snippet shows these additional properties to encrypt deployment data:
Following is a complete template, adapted from the template in [Tutorial: Deploy a multi-container group using a Resource Manager template](./container-instances-multi-container-group.md).
If you created and edited the template file on your desktop, you can upload it to your Cloud Shell directory by dragging the file into it.
438
+
439
+
Create a resource group with the [az group create][az-group-create] command.
440
+
441
+
```azurecli-interactive
442
+
az group create --name myResourceGroup --location eastus
443
+
```
444
+
445
+
Deploy the template with the [az deployment group create][az-deployment-group-create] command.
446
+
447
+
```azurecli-interactive
448
+
az deployment group create --resource-group myResourceGroup --template-file deployment-template.json
449
+
```
450
+
451
+
Within a few seconds, you should receive an initial response from Azure. Once the deployment completes, all data related to it persisted by the ACI service will be encrypted with the key you provided.
0 commit comments