Azure Data Explorer encrypts all data in a storage account at rest. By default, data is encrypted with Microsoft-managed keys. For additional control over encryption keys, you can supply customer-managed keys to use for data encryption.
Customer-managed keys must be stored in an Azure Key Vault. You can create your own keys and store them in a key vault, or you can use an Azure Key Vault API to generate keys. The Azure Data Explorer cluster and the key vault must be in the same region, but they can be in different subscriptions. For a detailed explanation on customer-managed keys, see customer-managed keys with Azure Key Vault.
This article shows you how to configure customer-managed keys.
Configure Azure Key Vault
To configure customer-managed keys with Azure Data Explorer, you must set two properties on the key vault: Soft Delete and Do Not Purge. These properties aren't enabled by default. To enable these properties, perform Enabling soft-delete and Enabling Purge Protection in PowerShell or Azure CLI on a new or existing key vault. Only RSA keys of size 2048 are supported. For more information about keys, see Key Vault keys.
To enable customer-managed keys for your cluster, first assign either a system-assigned or user-assigned managed identity to the cluster. You'll use this managed identity to grant the cluster permissions to access the key vault. To configure managed identities, see managed identities.
This following steps explain how to enable customer-managed keys encryption using the Azure portal. By default, Azure Data Explorer encryption uses Microsoft-managed keys. Configure your Azure Data Explorer cluster to use customer-managed keys and specify the key to associate with the cluster.
Select Settings > Encryption in left pane of portal.
In the Encryption pane, select On for the Customer-managed key setting.
Click Select Key.
In the Select key from Azure Key Vault window, select an existing Key vault from the dropdown list. If you select Create new to create a new Key Vault, you'll be routed to the Create Key Vault screen.
Select Key.
Version:
To ensure that this key always uses the latest key version, select the Always use current key version checkbox.
Otherwise, select Version.
Click Select.
Under Identity type, select System Assigned or User Assigned.
If you select User Assigned, pick a user assigned identity from the dropdown.
In the Encryption pane that now contains your key, select Save. When CMK creation succeeds, you'll see a success message in Notifications.
If you select system assigned identity when enabling customer-managed keys for your Azure Data Explorer cluster, you'll create a system assigned identity for the cluster if one doesn't exist. In addition, you'll be providing the required get, wrapKey, and unwrapKey permissions to your Azure Data Explorer cluster on the selected Key Vault and get the Key Vault properties.
Note
Select Off to remove the customer-managed key after it has been created.
The following sections explain how to configure customer-managed keys encryption using the Azure Data Explorer C# client.
To run the examples in this article, create an Azure AD application and service principal that can access resources. You can add role assignment at the subscription scope and get the required Azure AD Directory (tenant) ID, Application ID, and Application Secret.
The following code snippet demonstrates how to use the Microsoft Authentication Library (MSAL) to acquire an Azure AD application token to access your cluster. For the flow to succeed, the application must be registered with Azure AD and you must have the credentials for application authentication, such as an Azure AD-issued application key or an Azure AD-registered X.509v2 certificate.
Configure customer managed keys
By default, Azure Data Explorer encryption uses Microsoft-managed keys. Configure your Azure Data Explorer cluster to use customer-managed keys and specify the key to associate with the cluster.
Update your cluster by using the following code:
var tenantId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx"; // Azure AD Directory (tenant) ID
var clientId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx"; // Application ID
var clientSecret = "PlaceholderClientSecret"; // Application secret
var subscriptionId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx";
// Create a confidential authentication client for Azure AD:
var authClient = ConfidentialClientApplicationBuilder.Create(clientId)
.WithAuthority($"https://login.microsoftonline.com/{tenantId}")
.WithClientSecret(clientSecret) // can be replaced by .WithCertificate to authenticate with an X.509 certificate
.Build();
// Acquire application token
var result = authClient.AcquireTokenForClient(
new[] { "https://management.core.windows.net/.default" } // Define scopes for accessing Azure management plane
).ExecuteAsync().Result;
var credentials = new TokenCredentials(result.AccessToken, result.TokenType);
var kustoManagementClient = new KustoManagementClient(credentials) { SubscriptionId = subscriptionId };
var resourceGroupName = "testrg";
var clusterName = "mykustocluster";
var clusterPatch = new ClusterUpdate(
keyVaultProperties: new KeyVaultProperties(
keyName: "<keyName>",
keyVersion: "<keyVersion>", // Optional, leave as NULL for the latest version of the key.
keyVaultUri: "https://<keyVaultName>.vault.azure.net/",
userIdentity: "/subscriptions/<identitySubscriptionId>/resourcegroups/<identityResourceGroupName>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<identityName>" // Use NULL if you want to use system assigned identity.
)
);
await kustoManagementClient.Clusters.UpdateAsync(resourceGroupName, clusterName, clusterPatch);
Run the following command to check if your cluster was successfully updated:
var clusterData = await kustoManagementClient.Clusters.GetAsync(resourceGroupName, clusterName);
If the result contains ProvisioningState with the Succeeded value, then your cluster was successfully updated.
The following steps explain how to enable customer-managed keys encryption using Azure CLI client. By default, Azure Data Explorer encryption uses Microsoft-managed keys. Configure your Azure Data Explorer cluster to use customer-managed keys and specify the key to associate with the cluster.
Run the following command to sign in to Azure:
az login
Set the subscription where your cluster is registered. Replace MyAzureSub with the name of the Azure subscription that you want to use.
az account set --subscription MyAzureSub
Run the following command to set the new key with the cluster's system assigned identity
Run the following command and check the 'keyVaultProperties' property to verify the cluster updated successfully.
az kusto cluster show --cluster-name "mytestcluster" --resource-group "mytestrg"
The following steps explain how to enable customer-managed keys encryption using PowerShell. By default, Azure Data Explorer encryption uses Microsoft-managed keys. Configure your Azure Data Explorer cluster to use customer-managed keys and specify the key to associate with the cluster.
Run the following command to sign in to Azure:
Connect-AzAccount
Set the subscription where your cluster is registered.
The following steps explain how to configure customer-managed keys using Azure Resource Manager templates. By default, Azure Data Explorer encryption uses Microsoft-managed keys. In this step, configure your Azure Data Explorer cluster to use customer-managed keys and specify the key to associate with the cluster.
If you'd like to use a system assigned identity to access the key vault, leave userIdentity empty. Otherwise, set the identity's resource ID.
You can deploy the Azure Resource Manager template by using the Azure portal or using PowerShell.
When you create a new version of a key, you'll need to update the cluster to use the new version. First, call Get-AzKeyVaultKey to get the latest version of the key. Then update the cluster's key vault properties to use the new version of the key, as shown in Enable encryption with customer-managed keys.