Skip to content

Commit ab79c92

Browse files
authored
Merge pull request #100275 from orspod/2020-1-BYOK-docs
2020 1 byok docs
2 parents 5d8b493 + ad97a77 commit ab79c92

7 files changed

+436
-8
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: Configure customer-managed-keys using C#
3+
description: This article describes how to configure customer-managed keys encryption on your data in Azure Data Explorer.
4+
author: saguiitay
5+
ms.author: itsagui
6+
ms.reviewer: orspodek
7+
ms.service: data-explorer
8+
ms.topic: conceptual
9+
ms.date: 01/06/2020
10+
---
11+
12+
# Configure customer-managed-keys using C#
13+
14+
> [!div class="op_single_selector"]
15+
> * [C#](create-cluster-database-csharp.md)
16+
> * [Azure Resource Manager template](create-cluster-database-resource-manager.md)
17+
18+
[!INCLUDE [data-explorer-configure-customer-managed-keys](../../includes/data-explorer-configure-customer-managed-keys.md)]
19+
20+
## Configure encryption with customer-managed keys
21+
22+
This section shows you how to configure customer-managed keys encryption using the Azure Data Explorer C# client.
23+
24+
### Prerequisites
25+
26+
* If you don't have Visual Studio 2019 installed, you can download and use the **free** [Visual Studio 2019 Community Edition](https://www.visualstudio.com/downloads/). Make sure that you enable **Azure development** during the Visual Studio setup.
27+
28+
* If you don't have an Azure subscription, create a [free Azure account](https://azure.microsoft.com/free/) before you begin.
29+
30+
### Install C# Nuget
31+
32+
* Install the [Azure Data Explorer (Kusto) nuget package](https://www.nuget.org/packages/Microsoft.Azure.Management.Kusto/).
33+
34+
* Install the [Microsoft.IdentityModel.Clients.ActiveDirectory nuget package](https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory/) for authentication.
35+
36+
### Authentication
37+
38+
To run the examples in this article, [create an Azure AD application](/azure/active-directory/develop/howto-create-service-principal-portal) and service principal that can access resources. You can add role assignment at the subscription scope and get the required `Directory (tenant) ID`, `Application ID`, and `Client Secret`.
39+
40+
### Configure cluster
41+
42+
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.
43+
44+
1. Update your cluster by using the following code:
45+
46+
```csharp
47+
var tenantId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx";//Directory (tenant) ID
48+
var clientId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx";//Application ID
49+
var clientSecret = "xxxxxxxxxxxxxx";//Client Secret
50+
var subscriptionId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx";
51+
var authenticationContext = new AuthenticationContext($"https://login.windows.net/{tenantId}");
52+
var credential = new ClientCredential(clientId, clientSecret);
53+
var result = await authenticationContext.AcquireTokenAsync(resource: "https://management.core.windows.net/", clientCredential: credential);
54+
55+
var credentials = new TokenCredentials(result.AccessToken, result.AccessTokenType);
56+
57+
var kustoManagementClient = new KustoManagementClient(credentials)
58+
{
59+
SubscriptionId = subscriptionId
60+
};
61+
62+
var resourceGroupName = "testrg";
63+
var clusterName = "mykustocluster";
64+
var keyName = "myKey";
65+
var keyVersion = "5b52b20e8d8a42e6bd7527211ae32654";
66+
var keyVaultUri = "https://mykeyvault.vault.azure.net/";
67+
var keyVaultProperties = new KeyVaultProperties (keyName, keyVersion, keyVaultUri);
68+
var clusterUpdate = new ClusterUpdate(keyVaultProperties: keyVaultProperties);
69+
await kustoManagementClient.Clusters.UpdateAsync(resourceGroupName, clusterName, clusterUpdate);
70+
```
71+
72+
1. Run the following command to check if your cluster was successfully updated:
73+
74+
```csharp
75+
kustoManagementClient.Clusters.Get(resourceGroupName, clusterName);
76+
```
77+
78+
If the result contains `ProvisioningState` with the `Succeeded` value, then your cluster was successfully updated.
79+
80+
## Update the key version
81+
82+
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 [Configure cluster](#configure-cluster).
83+
84+
## Next steps
85+
86+
* [Secure Azure Data Explorer clusters in Azure](security.md)
87+
* [Configure managed identities for your Azure Data Explorer cluster](managed-identities.md)
88+
* [Secure your cluster in Azure Data Explorer - Azure portal](manage-cluster-security.md) by enabling encryption at rest.
89+
* [Configure customer-managed-keys using the Azure Resource Manager template](customer-managed-keys-resource-manager.md)
90+
91+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Configure customer-managed-keys in Azure Data Explorer using the Azure Resource Manager template
3+
description: This article describes how to configure customer-managed keys encryption on your data in Azure Data Explorer using the Azure Resource Manager template.
4+
author: saguiitay
5+
ms.author: itsagui
6+
ms.reviewer: orspodek
7+
ms.service: data-explorer
8+
ms.topic: conceptual
9+
ms.date: 01/06/2020
10+
---
11+
12+
# Configure customer-managed-keys using the Azure Resource Manager template
13+
14+
> [!div class="op_single_selector"]
15+
> * [C#](create-cluster-database-csharp.md)
16+
> * [Azure Resource Manager template](create-cluster-database-resource-manager.md)
17+
18+
[!INCLUDE [data-explorer-configure-customer-managed-keys](../../includes/data-explorer-configure-customer-managed-keys.md)]
19+
20+
## Configure encryption with customer-managed keys
21+
22+
In this section, you 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.
23+
24+
You can deploy the Azure Resource Manager template by using the Azure portal or using PowerShell.
25+
26+
```json
27+
{
28+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
29+
"contentVersion": "1.0.0.0",
30+
"parameters": {
31+
"clusterName": {
32+
"type": "string",
33+
"defaultValue": "[concat('kusto', uniqueString(resourceGroup().id))]",
34+
"metadata": {
35+
"description": "Name of the cluster to create"
36+
}
37+
},
38+
"location": {
39+
"type": "string",
40+
"defaultValue": "[resourceGroup().location]",
41+
"metadata": {
42+
"description": "Location for all resources."
43+
}
44+
}
45+
},
46+
"variables": {},
47+
"resources": [
48+
{
49+
"name": "[parameters('clusterName')]",
50+
"type": "Microsoft.Kusto/clusters",
51+
"sku": {
52+
"name": "Standard_D13_v2",
53+
"tier": "Standard",
54+
"capacity": 2
55+
},
56+
"apiVersion": "2019-09-07",
57+
"location": "[parameters('location')]",
58+
"properties": {
59+
"keyVaultProperties": {
60+
"keyVaultUri": "<keyVaultUri>",
61+
"keyName": "<keyName>",
62+
"keyVersion": "<keyVersion"
63+
}
64+
}
65+
}
66+
]
67+
}
68+
```
69+
70+
## Update the key version
71+
72+
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 [Configure encryption with customer-managed keys](#configure-encryption-with-customer-managed-keys).
73+
74+
## Next steps
75+
76+
* [Secure Azure Data Explorer clusters in Azure](security.md)
77+
* [Configure managed identities for your Azure Data Explorer cluster](managed-identities.md)
78+
* [Secure your cluster in Azure Data Explorer - Azure portal](manage-cluster-security.md) by enabling encryption at rest.
79+
* [Configure customer-managed-keys using C#](customer-managed-keys-csharp.md)
80+

articles/data-explorer/manage-cluster-security.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ ms.topic: conceptual
99
ms.date: 08/20/2019
1010
---
1111

12-
# Secure your cluster in Azure Data Explorer
12+
# Secure your cluster in Azure Data Explorer - Azure portal
1313

14-
[Azure Disk Encryption](/azure/security/azure-security-disk-encryption-overview) helps protect and safeguard your data to meet your organizational security and compliance commitments. It provides volume encryption for the OS and data disks of your cluster virtual machines. It also integrates with [Azure Key Vault](/azure/key-vault/) which allows us to control and manage the disk encryption keys and secrets, and ensure all data on the VM disks is encrypted at rest while in Azure Storage.
15-
16-
Your cluster security settings allow you to enable disk encryption on your cluster.
14+
[Azure Disk Encryption](/azure/security/azure-security-disk-encryption-overview) helps protect and safeguard your data to meet your organizational security and compliance commitments. It provides volume encryption for the OS and data disks of your cluster virtual machines. It also integrates with [Azure Key Vault](/azure/key-vault/), which allows us to control and manage the disk encryption keys and secrets, and ensure all data on the VM disks is encrypted.
1715

18-
## Enable encryption at rest
16+
## Enable encryption at rest in the Azure portal
1917

20-
Enabling [encryption at rest](/azure/security/fundamentals/encryption-atrest) on your cluster provides data protection for stored data (at rest).
18+
Your cluster security settings allow you to enable disk encryption on your cluster. Enabling [encryption at rest](/azure/security/fundamentals/encryption-atrest) on your cluster provides data protection for stored data (at rest).
2119

2220
1. In the Azure portal, go to your Azure Data Explorer cluster resource. Under the **Settings** heading, select **Security**.
2321

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
---
2+
title: How to configure managed identities for Azure Data Explorer cluster
3+
description: Learn how to configure managed identities for Azure Data Explorer cluster.
4+
author: saguiitay
5+
ms.author: itsagui
6+
ms.reviewer: orspodek
7+
ms.service: data-explorer
8+
ms.topic: conceptual
9+
ms.date: 01/06/2020
10+
---
11+
12+
# Configure managed identities for your Azure Data Explorer cluster
13+
14+
A [managed identity from Azure Active Directory](/azure/active-directory/managed-identities-azure-resources/overview) allows your cluster to easily access other AAD-protected resources such as Azure Key Vault. The identity is managed by the Azure platform and doesn't require you to provision or rotate any secrets. This article shows you how to create a managed identity for Azure Data Explorer clusters.
15+
16+
> [!Note]
17+
> Managed identities for Azure Data Explorer won't behave as expected if your app is migrated across subscriptions or tenants. The app will need to obtain a new identity, which can be done by disabling and re-enabling the feature using [remove an identity](#remove-an-identity). Access policies of downstream resources will also need to be updated to use the new identity.
18+
19+
## Add a system-assigned identity
20+
21+
Your cluster can be assigned a **system-assigned identity** that is tied to your cluster, and is deleted if your cluster is deleted. A cluster can only have one system-assigned identity. Creating a cluster with a system-assigned identity requires an additional property to be set on the cluster.
22+
23+
### Add a system-assigned identity using C#
24+
25+
To set up a managed identity using the Azure Data Explorer C# client, do the following:
26+
27+
* Install the [Azure Data Explorer (Kusto) NuGet package](https://www.nuget.org/packages/Microsoft.Azure.Management.Kusto/).
28+
* Install the [Microsoft.IdentityModel.Clients.ActiveDirectory NuGet package](https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory/) for authentication.
29+
* To run the following example, [create an Azure AD application](/azure/active-directory/develop/howto-create-service-principal-portal) and service principal that can access resources. You can add role assignment at the subscription scope and get the required `Directory (tenant) ID`, `Application ID`, and `Client Secret`.
30+
31+
#### Create or update your cluster
32+
33+
1. Create or update your cluster using the `Identity` property:
34+
35+
```csharp
36+
var tenantId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx";//Directory (tenant) ID
37+
var clientId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx";//Application ID
38+
var clientSecret = "xxxxxxxxxxxxxx";//Client Secret
39+
var subscriptionId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx";
40+
var authenticationContext = new AuthenticationContext($"https://login.windows.net/{tenantId}");
41+
var credential = new ClientCredential(clientId, clientSecret);
42+
var result = await authenticationContext.AcquireTokenAsync(resource: "https://management.core.windows.net/", clientCredential: credential);
43+
44+
var credentials = new TokenCredentials(result.AccessToken, result.AccessTokenType);
45+
46+
var kustoManagementClient = new KustoManagementClient(credentials)
47+
{
48+
SubscriptionId = subscriptionId
49+
};
50+
51+
var resourceGroupName = "testrg";
52+
var clusterName = "mykustocluster";
53+
var location = "Central US";
54+
var skuName = "Standard_D13_v2";
55+
var tier = "Standard";
56+
var capacity = 5;
57+
var sku = new AzureSku(skuName, tier, capacity);
58+
var identity = new Identity(IdentityType.SystemAssigned);
59+
var cluster = new Cluster(location, sku, identity: identity);
60+
await kustoManagementClient.Clusters.CreateOrUpdateAsync(resourceGroupName, clusterName, cluster);
61+
```
62+
63+
2. Run the following command to check if your cluster was successfully created or updated with an identity:
64+
65+
```csharp
66+
kustoManagementClient.Clusters.Get(resourceGroupName, clusterName);
67+
```
68+
69+
If the result contains `ProvisioningState` with the `Succeeded` value, then the cluster was created or updated, and should have the following properties:
70+
71+
```csharp
72+
var principalId = cluster.Identity.PrincipalId;
73+
var tenantId = cluster.Identity.TenantId;
74+
```
75+
76+
`PrincipalId` and `TenantId` are replaced with GUIDs. The `TenantId` property identifies the AAD tenant to which the identity belongs. The `PrincipalId` is a unique identifier for the cluster's new identity. Within AAD, the service principal has the same name that you gave to your App Service or Azure Functions instance.
77+
78+
### Add a system-assigned identity using an Azure Resource Manager template
79+
80+
An Azure Resource Manager template can be used to automate deployment of your Azure resources. To learn more about deploying to Azure Data Explorer, see [Create an Azure Data Explorer cluster and database by using an Azure Resource Manager template](create-cluster-database-resource-manager.md).
81+
82+
Adding the system-assigned type tells Azure to create and manage the identity for your cluster. Any resource of type `Microsoft.Kusto/clusters` can be created with an identity by including the following property in the resource definition:
83+
84+
```json
85+
"identity": {
86+
"type": "SystemAssigned"
87+
}
88+
```
89+
90+
For example:
91+
92+
```json
93+
{
94+
"apiVersion": "2019-09-07",
95+
"type": "Microsoft.Kusto/clusters",
96+
"name": "[variables('clusterName')]",
97+
"location": "[resourceGroup().location]",
98+
"identity": {
99+
"type": "SystemAssigned"
100+
},
101+
"properties": {
102+
"trustedExternalTenants": [],
103+
"virtualNetworkConfiguration": null,
104+
"optimizedAutoscale": null,
105+
"enableDiskEncryption": false,
106+
"enableStreamingIngest": false,
107+
}
108+
}
109+
```
110+
111+
When the cluster is created, it has the following additional properties:
112+
113+
```json
114+
"identity": {
115+
"type": "SystemAssigned",
116+
"tenantId": "<TENANTID>",
117+
"principalId": "<PRINCIPALID>"
118+
}
119+
```
120+
121+
`<TENANTID>` and `<PRINCIPALID>` are replaced with GUIDs. The `TenantId` property identifies the AAD tenant to which the identity belongs. The `PrincipalId` is a unique identifier for the cluster's new identity. Within AAD, the service principal has the same name that you gave to your App Service or Azure Functions instance.
122+
123+
## Remove an identity
124+
125+
Removing a system-assigned identity will also delete it from AAD. System-assigned identities are also automatically removed from AAD when the cluster resource is deleted. A system-assigned identity can be removed by disabling the feature:
126+
127+
```json
128+
"identity": {
129+
"type": "None"
130+
}
131+
```
132+
133+
## Next steps
134+
135+
* [Secure Azure Data Explorer clusters in Azure](security.md)
136+
* [Secure your cluster in Azure Data Explorer - Azure portal](manage-cluster-security.md) by enabling encryption at rest.
137+
* [Configure customer-managed-keys using C#](customer-managed-keys-csharp.md)
138+
* [Configure customer-managed-keys using the Azure Resource Manager template](customer-managed-keys-resource-manager.md)

0 commit comments

Comments
 (0)