|
| 1 | +--- |
| 2 | +title: Encrypt Data Factory with Customer Managed Key (CMK) |
| 3 | +description: Enhance Data Factory security with Bring Your Own Key (BYOK) |
| 4 | +services: data-factory |
| 5 | +documentationcenter: '' |
| 6 | + |
| 7 | +author: chez-charlie |
| 8 | +ms.service: data-factory |
| 9 | +ms.topic: quickstart |
| 10 | +ms.date: 05/08/2020 |
| 11 | +ms.author: chez |
| 12 | +ms.reviewer: mariozi |
| 13 | +--- |
| 14 | +# Enhance Data Factory Security and Configure customer-managed keys with Azure Key Vault |
| 15 | + |
| 16 | +[!INCLUDE[appliesto-adf-xxx-md](includes/appliesto-adf-xxx-md.md)] |
| 17 | + |
| 18 | +Azure Data Factory encrypts data at rest, including entity definitions, any data cached while runs are in progress, and data cached for Data Preview. By default, data is encrypted with a randomly generated Microsoft-manged key that is uniquely assigned to your data factory. For additional security guarantees, you can now enable Bring Your Own Key (BYOK) with customer-managed keys feature in Azure Data Factory. When you specify a customer-managed key, Data Factory uses __both__ the factory system key and the CMK to encrypt customer data. Missing either would result in Deny of Access to data and factory. |
| 19 | + |
| 20 | +Azure Key Vault is required to store customer-managed keys. You can either create your own keys and store them in a key vault, or you can use the Azure Key Vault APIs to generate keys. Key vault and Data Factory must be in the same Azure Active Directory (Azure AD) tenant and in the same region, but they may be in different subscriptions. For more information about Azure Key Vault, see [What is Azure Key Vault?](../key-vault/general/overview.md) |
| 21 | + |
| 22 | +[!NOTE] For now, customer-managed key can only be configured on an empty Data Factory: no linked service, no pipeline, no data sets, nothing. Consider enable customer-managed key right after factory creation. |
| 23 | + |
| 24 | +## About Customer-Managed Keys |
| 25 | + |
| 26 | +The following diagram shows how Data Factory uses Azure Active Directory and Azure Key Vault to make requests using the customer-managed key: |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +The following list explains the numbered steps in the diagram: |
| 31 | + |
| 32 | +1. An Azure Key Vault admin grants permissions to encryption keys to the managed identity that's associated with the Data Factory |
| 33 | +1. A Data Factory admin enables customer-managed key feature in the factory |
| 34 | +1. Data Factory uses the managed identity that's associated with the factory to authenticate access to Azure Key Vault via Azure Active Directory |
| 35 | +1. Data Factory wraps the factory encryption key with the customer key in Azure Key Vault |
| 36 | +1. For read/write operations, Data Factory sends requests to Azure Key Vault to unwrap the account encryption key to perform encryption and decryption operations |
| 37 | + |
| 38 | +## Prerequisites - Configure Azure Key Vault and Generate Keys |
| 39 | + |
| 40 | +### Enable Soft Delete and Do Not Purge on Azure Key Vault |
| 41 | + |
| 42 | +Using customer-managed keys with Data Factory requires two properties to be set on the Key Vault, __Soft Delete__ and __Do Not Purge__. These properties can be enabled using either PowerShell or Azure CLI on a new or existing key vault. To learn how to enable these properties on an existing key vault, see the sections titled _Enabling soft-delete_ and _Enabling Purge Protection_ in one of the following articles: |
| 43 | + |
| 44 | +- [How to use soft-delete with PowerShell](../key-vault/general/soft-delete-powershell.md) |
| 45 | +- [How to use soft-delete with CLI](../key-vault/general/soft-delete-cli.md) |
| 46 | + |
| 47 | +If you are creating a new Azure Key Vault through Azure Portal, __Soft Delete__ and __Do Not Purge__ can be enabled as follows: |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +### Grant Data Factory Access to Key Vault |
| 52 | + |
| 53 | +Make sure that Azure Key Vault and Azure Data Factory are in the same Azure Active Directory (Azure AD) tenant and in the _same region_. From Azure Key Vault access control, grant data factory's Managed Service Identity (MSI) following permissions: _Get_, _Unwrap Key_, and _Wrap Key_. These permissions are required to enable customer-managed keys in Data Factory. |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +### Generate or Upload customer-managed key to Key Vault |
| 58 | + |
| 59 | +You can either create your own keys and store them in a key vault, or you can use the Azure Key Vault APIs to generate keys. Note that only 2048-bit RSA keys are supported with Data Factory encryption. For more information, see [About keys, secrets, and certificates](../key-vault/general/about-keys-secrets-certificates.md). |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +## Enable Customer-Managed Keys |
| 64 | + |
| 65 | +1. Ensure the Data Factory is empty: no linked service, no pipeline, and no data set, nothing. For now, deploying customer-managed key to a non-empty factory will result in an error. |
| 66 | + |
| 67 | +2. To locate the key URI in the Azure portal, navigate to Azure Key Vault, and select the Keys setting. Select the wanted key, then click the key to view its versions. Select a key version to view the settings |
| 68 | + |
| 69 | +3. Copy the value of the Key Identifier field, which provides the URI |
| 70 | + |
| 71 | +  |
| 72 | + |
| 73 | +4. Launch Azure Data Factory portal, and using the navigation bar on the left, jump to Data Factory Home Page |
| 74 | + |
| 75 | +5. Click on the __Customer manged key__ icon |
| 76 | + |
| 77 | +  |
| 78 | + |
| 79 | +6. Enter the URI for customer-managed key that you copied before |
| 80 | + |
| 81 | +7. Click __Save__ and customer-manged key encryption is enabled for Data Factory |
| 82 | + |
| 83 | +## Update Key Version |
| 84 | + |
| 85 | +When you create a new version of a key, update data factory to use the new version. Follow similar steps as described in section _Enable Customer-Managed Keys_, including: |
| 86 | + |
| 87 | +1. Locate the URI for the new key version through Azure Key Vault Portal |
| 88 | + |
| 89 | +1. Navigate to __Customer managed key__ setting |
| 90 | + |
| 91 | +1. Replace and paste in the URI for the new key |
| 92 | + |
| 93 | +1. Click __Save__ and Data Factory will now encrypt with the new key version |
| 94 | + |
| 95 | +## Use a Different Key |
| 96 | + |
| 97 | +To change key used for Data Factory encryption, you have to manually update the settings in Data Factory. Follow similar steps as described in section _Enable Customer-Managed Keys_, including: |
| 98 | + |
| 99 | +1. Locate the URI for the new key through Azure Key Vault Portal |
| 100 | + |
| 101 | +1. Navigate to __Customer manged key__ setting |
| 102 | + |
| 103 | +1. Replace and paste in the URI for the new key |
| 104 | + |
| 105 | +1. Click __Save__ and Data Factory will now encrypt with the new key |
| 106 | + |
| 107 | +## Disable Customer-Managed Keys |
| 108 | + |
| 109 | +By design, once customer-managed key feature is enabled, you cannot remove the extra security step. We will always expect a customer provided key to encrypt factory and data. |
| 110 | + |
| 111 | +## Next steps |
| 112 | + |
| 113 | +Go through the [tutorials](tutorial-copy-data-dot-net.md) to learn about using Data Factory in more scenarios. |
0 commit comments