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/container-instances/container-instances-encrypt-data.md
+239-4Lines changed: 239 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,8 +17,6 @@ When running Azure Container Instances (ACI) resources in the cloud, the ACI ser
17
17
18
18
Data in ACI is encrypted and decrypted using 256-bit AES encryption. It is enabled for all ACI deployments, and you don't need to modify your deployment or containers to take advantage of this encryption. This includes metadata about the deployment, environment variables, keys being passed into your containers, and logs persisted after your containers are stopped so you can still see them. Encryption does not affect your container group performance, and there is no additional cost for encryption.
19
19
20
-
## Encryption key management
21
-
22
20
You can rely on Microsoft-managed keys for the encryption of your container data, or you can manage the encryption with your own keys. The following table compares these options:
@@ -28,10 +26,12 @@ You can rely on Microsoft-managed keys for the encryption of your container data
28
26
|**Key rotation responsibility**| Microsoft | Customer |
29
27
|**Key access**| Microsoft only | Microsoft, Customer |
30
28
31
-
The rest of the document covers the steps required to encrypt your ACI deployment data with your key (customer-managed key).
29
+
This article reviews two flows for encrypting data with a customer-managed key:
30
+
* Encrypt data with a customer-managed key stored in a standard Azure Key Vault
31
+
* Encrypt data with a customer-managed key stored in a network-protected Azure Key Vault with [Trusted Services](../key-vault/general/network-security.md) enabled.
32
32
33
+
## Encrypt data with a customer-managed key stored in a standard Azure Key Vau
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.
@@ -237,6 +237,241 @@ az deployment group create --resource-group myResourceGroup --template-file depl
237
237
238
238
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.
239
239
240
+
## Encrypt data with a customer-managed key in a network protected Azure Key Vault with Trusted Services enabled
241
+
242
+
### Create a Key Vault resource
243
+
244
+
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). To start, do not apply any network-limitations so we can add necessary keys to the vault. In subsequent steps, we will add network-limitations and enable trusted services.
245
+
246
+
For the properties of your key vault, use the following guidelines:
247
+
* Name: A unique name is required.
248
+
* Subscription: Choose a subscription.
249
+
* Under Resource Group, either choose an existing resource group, or create new and enter a resource group name.
250
+
* In the Location pull-down menu, choose a location.
251
+
* You can leave the other options to their defaults or pick based on additional requirements.
252
+
253
+
> [!IMPORTANT]
254
+
> 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.
255
+
### Generate a new key
256
+
257
+
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. Make sure to capture key name and version for subsequent steps.
258
+
259
+

260
+
261
+
### Create a user-assigned managed identity for your container group
262
+
Create an identity in your subscription using the [az identity create](/cli/azure/identity#az-identity-create) command. You can use the same resource group used to create the key vault, or use a different one.
263
+
264
+
```azurecli-interactive
265
+
az identity create \
266
+
--resource-group myResourceGroup \
267
+
--name myACIId
268
+
```
269
+
270
+
To use the identity in the following steps, use the [az identity show](/cli/azure/identity#az-identity-show) command to store the identity's service principal ID and resource ID in variables.
271
+
272
+
```azurecli-interactive
273
+
# Get service principal ID of the user-assigned identity
274
+
spID=$(az identity show \
275
+
--resource-group myResourceGroup \
276
+
--name myACIId \
277
+
--query principalId --output tsv)
278
+
```
279
+
280
+
### Set access policy
281
+
282
+
Create a new access policy for allowing the user-assigned identity to access and unwrap your key for encryption purposes.
283
+
284
+
```azurecli-interactive
285
+
az keyvault set-policy \
286
+
--name mykeyvault \
287
+
--resource-group myResourceGroup \
288
+
--object-id $spID \
289
+
--key-permissions get unwrapKey
290
+
```
291
+
292
+
### Modify Azure Key Vault's network permissions
293
+
The following commands set up an Azure Firewall for your Azure Key Vault and allow Azure Trusted Services such as ACI access.
294
+
295
+
```azurecli-interactive
296
+
az keyvault update \
297
+
--name mykeyvault \
298
+
--resource-group myResourceGroup \
299
+
--default-action Deny
300
+
```
301
+
302
+
```azurecli-interactive
303
+
az keyvault update \
304
+
--name mykeyvault \
305
+
--resource-group myResourceGroup \
306
+
--bypass AzureServices
307
+
```
308
+
309
+
### Modify your JSON deployment template
310
+
311
+
> [!IMPORTANT]
312
+
> Encrypting deployment data with a customer-managed key is available in the 2022-09-01 API version or newer. The 2022-09-01 API version is only available via ARM or REST. If you have any issues with this, please reach out to Azure Support.
313
+
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).
314
+
* Under `resources`, set `apiVersion` to `2022-09-01`.
315
+
* Under the container group properties section of the deployment template, add an `encryptionProperties`, which contains the following values:
316
+
*`vaultBaseUrl`: the DNS Name of your key vault. This can be found on the overview blade of the key vault resource in Portal
317
+
*`keyName`: the name of the key generated earlier
318
+
*`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)
319
+
*`identity`: this is the resource URI of the Managed Identity instance created earlier
320
+
* Under the container group properties, add a `sku` property with value `Standard`. The `sku` property is required in API version 2022-09-01.
321
+
* Under resources, add the `identity` object required to use Managed Identity with ACI, which contains the following values:
322
+
*`type`: the type of the identity being used (either user-assigned or system-assigned). This case will be set to "UserAssigned"
323
+
*`userAssignedIdentities`: the resourceURI of the same user-assigned identity used above in the `encryptionProperties` object.
324
+
325
+
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.
461
+
462
+
Create a resource group with the [az group create][az-group-create] command.
463
+
464
+
```azurecli-interactive
465
+
az group create --name myResourceGroup --location eastus
466
+
```
467
+
468
+
Deploy the template with the [az deployment group create][az-deployment-group-create] command.
469
+
470
+
```azurecli-interactive
471
+
az deployment group create --resource-group myResourceGroup --template-file deployment-template.json
472
+
```
473
+
474
+
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