Skip to content

Commit 5b9713f

Browse files
authored
Merge pull request #111529 from dagiro/CMK2
CMK2
2 parents cb98d77 + c898c8c commit 5b9713f

File tree

1 file changed

+215
-37
lines changed

1 file changed

+215
-37
lines changed

articles/hdinsight/disk-encryption.md

Lines changed: 215 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.author: hrasheed
66
ms.reviewer: hrasheed
77
ms.service: hdinsight
88
ms.topic: conceptual
9-
ms.date: 02/20/2020
9+
ms.date: 04/15/2020
1010
---
1111

1212
# Customer-managed key disk encryption
@@ -119,6 +119,220 @@ az hdinsight create -t spark -g MyResourceGroup -n MyCluster \
119119
--assign-identity MyMSI
120120
```
121121

122+
### Using Azure Resource Manager templates
123+
124+
The following example shows how to use an Azure Resource Manager template to create a new Apache Spark cluster with disk encryption enabled. For more information, see [What are ARM templates?](https://docs.microsoft.com/azure/azure-resource-manager/templates/overview).
125+
126+
This example uses PowerShell to call the template.
127+
128+
```powershell
129+
$templateFile = "azuredeploy.json"
130+
$ResourceGroupName = "MyResourceGroup"
131+
$clusterName = "MyCluster"
132+
$password = ConvertTo-SecureString 'HttpPassword1234!' -AsPlainText -Force
133+
$diskEncryptionVaultUri = "https://MyKeyVault.vault.azure.net"
134+
$diskEncryptionKeyName = "SparkClusterKey"
135+
$diskEncryptionKeyVersion = "00000000000000000000000000000000"
136+
$managedIdentityName = "MyMSI"
137+
138+
New-AzResourceGroupDeployment `
139+
-Name mySpark `
140+
-TemplateFile $templateFile `
141+
-ResourceGroupName $ResourceGroupName `
142+
-clusterName $clusterName `
143+
-clusterLoginPassword $password `
144+
` -sshPassword $password `
145+
-diskEncryptionVaultUri $diskEncryptionVaultUri `
146+
-diskEncryptionKeyName $diskEncryptionKeyName `
147+
-diskEncryptionKeyVersion $diskEncryptionKeyVersion `
148+
-managedIdentityName $managedIdentityName
149+
```
150+
151+
The contents of the resource management template, `azuredeploy.json`:
152+
153+
```json
154+
{
155+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
156+
"contentVersion": "0.9.0.0",
157+
"parameters": {
158+
"clusterName": {
159+
"type": "string",
160+
"metadata": {
161+
"description": "The name of the HDInsight cluster to create."
162+
}
163+
},
164+
"clusterLoginUserName": {
165+
"type": "string",
166+
"defaultValue": "admin",
167+
"metadata": {
168+
"description": "These credentials can be used to submit jobs to the cluster and to log into cluster dashboards."
169+
}
170+
},
171+
"clusterLoginPassword": {
172+
"type": "securestring",
173+
"metadata": {
174+
"description": "The password must be at least 10 characters in length and must contain at least one digit, one non-alphanumeric character, and one upper or lower case letter."
175+
}
176+
},
177+
"location": {
178+
"type": "string",
179+
"defaultValue": "[resourceGroup().location]",
180+
"metadata": {
181+
"description": "The location where all azure resources will be deployed."
182+
}
183+
},
184+
"sshUserName": {
185+
"type": "string",
186+
"defaultValue": "sshuser",
187+
"metadata": {
188+
"description": "These credentials can be used to remotely access the cluster."
189+
}
190+
},
191+
"sshPassword": {
192+
"type": "securestring",
193+
"metadata": {
194+
"description": "The password must be at least 10 characters in length and must contain at least one digit, one non-alphanumeric character, and one upper or lower case letter."
195+
}
196+
},
197+
"headNodeSize": {
198+
"type": "string",
199+
"defaultValue": "Standard_D12_v2",
200+
"metadata": {
201+
"description": "The VM size of the head nodes."
202+
}
203+
},
204+
"workerNodeSize": {
205+
"type": "string",
206+
"defaultValue": "Standard_D13_v2",
207+
"metadata": {
208+
"description": "The VM size of the worker nodes."
209+
}
210+
},
211+
"diskEncryptionVaultUri": {
212+
"type": "string",
213+
"metadata": {
214+
"description": "The Key Vault DNSname."
215+
}
216+
},
217+
"diskEncryptionKeyName": {
218+
"type": "string",
219+
"metadata": {
220+
"description": "The Key Vault key name."
221+
}
222+
},
223+
"diskEncryptionKeyVersion": {
224+
"type": "string",
225+
"metadata": {
226+
"description": "The Key Vault key version for the selected key."
227+
}
228+
},
229+
"managedIdentityName": {
230+
"type": "string",
231+
"metadata": {
232+
"description": "The user-assigned managed identity."
233+
}
234+
}
235+
},
236+
"variables": {
237+
"defaultStorageAccount": {
238+
"name": "[uniqueString(resourceGroup().id)]",
239+
"type": "Standard_LRS"
240+
}
241+
},
242+
"resources": [
243+
{
244+
"type": "Microsoft.Storage/storageAccounts",
245+
"name": "[variables('defaultStorageAccount').name]",
246+
"location": "[parameters('location')]",
247+
"apiVersion": "2019-06-01",
248+
"sku": {
249+
"name": "[variables('defaultStorageAccount').type]"
250+
},
251+
"kind": "Storage",
252+
"properties": {}
253+
},
254+
{
255+
"apiVersion": "2018-06-01-preview",
256+
"name": "[parameters('clusterName')]",
257+
"type": "Microsoft.HDInsight/clusters",
258+
"location": "[parameters('location')]",
259+
"properties": {
260+
"clusterVersion": "3.6",
261+
"osType": "Linux",
262+
"tier": "standard",
263+
"clusterDefinition": {
264+
"kind": "spark",
265+
"componentVersion": {
266+
"Spark": "2.3"
267+
},
268+
"configurations": {
269+
"gateway": {
270+
"restAuthCredential.isEnabled": true,
271+
"restAuthCredential.username": "[parameters('clusterLoginUserName')]",
272+
"restAuthCredential.password": "[parameters('clusterLoginPassword')]"
273+
}
274+
}
275+
},
276+
"storageProfile": {
277+
"storageaccounts": [
278+
{
279+
"name": "[replace(replace(reference(resourceId('Microsoft.Storage/storageAccounts', variables('defaultStorageAccount').name), '2019-06-01').primaryEndpoints.blob,'https://',''),'/','')]",
280+
"isDefault": true,
281+
"container": "[parameters('clusterName')]",
282+
"key": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('defaultStorageAccount').name), '2019-06-01').keys[0].value]"
283+
}
284+
]
285+
},
286+
"computeProfile": {
287+
"roles": [
288+
{
289+
"name": "headnode",
290+
"minInstanceCount": 1,
291+
"targetInstanceCount": 2,
292+
"hardwareProfile": {
293+
"vmSize": "[parameters('headNodeSize')]"
294+
},
295+
"osProfile": {
296+
"linuxOperatingSystemProfile": {
297+
"username": "[parameters('sshUserName')]",
298+
"password": "[parameters('sshPassword')]"
299+
},
300+
},
301+
},
302+
{
303+
"name": "workernode",
304+
"targetInstanceCount": 1,
305+
"hardwareProfile": {
306+
"vmSize": "[parameters('workerNodeSize')]"
307+
},
308+
"osProfile": {
309+
"linuxOperatingSystemProfile": {
310+
"username": "[parameters('sshUserName')]",
311+
"password": "[parameters('sshPassword')]"
312+
},
313+
},
314+
}
315+
]
316+
},
317+
"minSupportedTlsVersion": "1.2",
318+
"diskEncryptionProperties": {
319+
"vaultUri": "[parameters('diskEncryptionVaultUri')]",
320+
"keyName": "[parameters('diskEncryptionKeyName')]",
321+
"keyVersion": "[parameters('diskEncryptionKeyVersion')]",
322+
"msiResourceId": "[resourceID('Microsoft.ManagedIdentity/userAssignedIdentities/', parameters('managedIdentityName'))]"
323+
}
324+
},
325+
"identity": {
326+
"type": "UserAssigned",
327+
"userAssignedIdentities": {
328+
"[resourceID('Microsoft.ManagedIdentity/userAssignedIdentities/', parameters('managedIdentityName'))]": {}
329+
}
330+
}
331+
}
332+
]
333+
}
334+
```
335+
122336
## Rotating the encryption key
123337

124338
There might be scenarios where you might want to change the encryption keys used by the HDInsight cluster after it has been created. This can be easily via the portal. For this operation, the cluster must have access to both the current key and the intended new key, otherwise the rotate key operation will fail.
@@ -142,42 +356,6 @@ az hdinsight rotate-disk-encryption-key \
142356
--resource-group MyResourceGroup
143357
```
144358

145-
## Azure Resource Manager templates
146-
147-
To use customer managed keys by using a Resource Manager template, update your template with the following changes:
148-
149-
1. In the **azuredeploy.json** file, add the following property to the resources" object:
150-
151-
```json
152-
"diskEncryptionProperties":
153-
{
154-
"vaultUri": "[parameters('diskEncryptionVaultUri')]",
155-
"keyName": "[parameters('diskEncryptionKeyName')]",
156-
"keyVersion": "[parameters('diskEncryptionKeyVersion')]",
157-
"msiResourceId": "[parameters('diskEncryptionMsiResourceId')]"
158-
}
159-
160-
1. In the **azuredeploy.parameters.json** file, add the following parameters. You can get the values of these parameters from the Key Vault URI and the managed Identity. For example, if you have the following URI and identity values,
161-
* Sample key vault URI: https://<KeyVault_Name>.vault.azure.net/keys/clusterkey/<Cluster_Key_Value>
162-
* Sample user-assigned managed identity: "/subscriptions/<subscriptionID>/resourcegroups/<ResourceGroup_Name>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<MSI_Name>
163-
164-
The parameters in the **azuredeploy.parameters.json** file are:
165-
166-
```json
167-
"diskEncryptionVaultUri": {
168-
"value": "https://<KeyVault_Name>.vault.azure.net"
169-
},
170-
"diskEncryptionKeyName": {
171-
"value": "clusterkey"
172-
},
173-
"diskEncryptionKeyVersion": {
174-
"value": "<Cluster_Key_Value>"
175-
},
176-
"diskEncryptionMsiResourceId": {
177-
"value": "/subscriptions/<subscriptionID>/resourcegroups/<ResourceGroup_Name>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<MSI_Name>"
178-
}
179-
```
180-
181359
## FAQ for customer-managed key encryption
182360

183361
**How does the HDInsight cluster access my key vault?**

0 commit comments

Comments
 (0)