Skip to content

Commit 59ed31e

Browse files
1. Converted Parameters that are using ARM Template built-in functions to variables 2. Generating GUID's for RBAGUID1 and RBAGUID2 in variables3. Updated all references --> paramerters --> Variables (#100)
Co-authored-by: Ian Hellen <[email protected]>
1 parent 28ac16f commit 59ed31e

File tree

1 file changed

+35
-76
lines changed

1 file changed

+35
-76
lines changed

Automated-Notebooks/DeploymentTemplate.json

Lines changed: 35 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "string",
77
"defaultValue": "autonotebook",
88
"metadata": {
9-
"description": "The name of you Virtual Machine used to execute notebooks."
9+
"description": "The name of your Virtual Machine used to execute notebooks."
1010
}
1111
},
1212
"adminUsername": {
@@ -17,8 +17,8 @@
1717
}
1818
},
1919
"authenticationType": {
20-
"type": "string",
21-
"defaultValue": "sshPublicKey",
20+
"type": "string",
21+
"defaultValue" : "sshPublicKey",
2222
"allowedValues": [
2323
"sshPublicKey",
2424
"password"
@@ -32,14 +32,7 @@
3232
"metadata": {
3333
"description": "SSH Key or password for the Virtual Machine. SSH key is recommended."
3434
}
35-
},
36-
"dnsLabelPrefix": {
37-
"type": "string",
38-
"defaultValue": "[toLower(concat('autonotebooks-', uniqueString(resourceGroup().id)))]",
39-
"metadata": {
40-
"description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
41-
}
42-
},
35+
},
4336
"ubuntuOSVersion": {
4437
"type": "string",
4538
"defaultValue": "18.04-LTS",
@@ -52,99 +45,65 @@
5245
"metadata": {
5346
"description": "The Ubuntu version for the VM. This will pick a fully patched image of this given Ubuntu version."
5447
}
55-
},
56-
"location": {
57-
"type": "string",
58-
"defaultValue": "[resourceGroup().location]",
59-
"metadata": {
60-
"description": "Location for all resources."
61-
}
62-
},
48+
},
6349
"VmSize": {
6450
"type": "string",
6551
"defaultValue": "Standard_B2s",
6652
"metadata": {
6753
"description": "The size of the VM"
6854
}
69-
},
70-
"virtualNetworkName": {
71-
"type": "string",
72-
"defaultValue": "[concat(parameters('vmName'),'-VNET')]",
73-
"metadata": {
74-
"description": "Name of the VNET"
75-
}
76-
},
77-
"subnetName": {
78-
"type": "string",
79-
"defaultValue": "[concat(parameters('vmName'),'-subnet')]",
80-
"metadata": {
81-
"description": "Name of the subnet in the virtual network"
82-
}
83-
},
84-
"networkSecurityGroupName": {
85-
"type": "string",
86-
"defaultValue": "[concat(parameters('vmName'),'-NSG')]",
87-
"metadata": {
88-
"description": "Name of the Network Security Group"
89-
}
90-
},
55+
},
9156
"SentinelRG" :{
92-
"type": "string",
93-
"defaultValue": "[resourceGroup().id]",
57+
"type": "string",
9458
"metadata": {
9559
"description": "The name of the Resource Group the Sentinel Workspace is in - change if RG is different from RG this VM is being deployed in"
9660
}
9761
},
9862
"SentinelSub" :{
99-
"type": "string",
100-
"defaultValue": "[subscription().subscriptionId]",
63+
"type": "string",
10164
"metadata": {
10265
"description": "The ID of the subscription the Sentinel Workspace is in - change if RG is different from RG this VM is being deployed in"
10366
}
10467
},
10568
"AzureMLSub" :{
106-
"type": "string",
107-
"defaultValue": "[subscription().subscriptionId]",
69+
"type": "string",
10870
"metadata": {
10971
"description": "The ID of the subscription the Azure ML Workspace is in - change if RG is different from RG this VM is being deployed in"
11072
}
11173
},
11274
"AzureMLRG" :{
113-
"type": "string",
114-
"defaultValue": "[resourceGroup().id]",
75+
"type": "string",
11576
"metadata": {
11677
"description": "The name of the Resource Group the Azure ML Workspace is in - change if RG is different from RG this VM is being deployed in"
11778
}
11879
},
11980
"builtInRoleType1": {
12081
"type": "string",
12182
"defaultValue": "Azure Sentinel Responder"
122-
},
123-
"rbacGuid1": {
124-
"type": "string",
125-
"defaultValue": "[newGuid()]"
126-
},
83+
},
12784
"builtInRoleType2": {
12885
"type": "string",
12986
"defaultValue": "Reader"
130-
},
131-
"rbacGuid2": {
132-
"type": "string",
133-
"defaultValue": "[newGuid()]"
134-
}
87+
}
13588
},
13689
"variables": {
13790
"rbac1Scope": "[concat('/subscriptions/', parameters('SentinelSub'), '/resourceGroups/', parameters('SentinelRG'))]",
13891
"rbac2Scope": "[concat('/subscriptions/', parameters('AzureMLSub'), '/resourceGroups/', parameters('AzureMLRG'))]",
92+
"virtualNetworkName":"[concat(parameters('vmName'),'-VNET')]",
93+
"subnetName":"[concat(parameters('vmName'),'-subnet')]",
13994
"vmResourceId": "[resourceId('Microsoft.Compute/virtualMachines/', parameters('vmName'))]",
14095
"Reader": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]",
14196
"Azure Sentinel Responder": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', '3e150937-b8fe-4cfb-8069-0eaf05ecd056')]",
14297
"publicIpAddressName": "[concat(parameters('vmName'), 'PublicIP' )]",
14398
"networkInterfaceName": "[concat(parameters('vmName'),'NetInt')]",
144-
"subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworkName'), parameters('subnetName'))]",
99+
"subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]",
145100
"osDiskType": "Standard_LRS",
146101
"subnetAddressPrefix": "10.1.0.0/24",
147102
"addressPrefix": "10.1.0.0/16",
103+
"dnsLabelPrefix": "[toLower(concat('autonotebooks-', uniqueString(resourceGroup().id)))]",
104+
"networkSecurityGroupName":"[concat(parameters('vmName'),'-NSG')]",
105+
"rbacGuid1":"[guid(subscription().subscriptionId, deployment().name)]",
106+
"rbacGuid2":"[guid(resourceGroup().id, deployment().name)]",
148107
"linuxConfiguration": {
149108
"disablePasswordAuthentication": true,
150109
"ssh": {
@@ -162,10 +121,10 @@
162121
"type": "Microsoft.Network/networkInterfaces",
163122
"apiVersion": "2020-06-01",
164123
"name": "[variables('networkInterfaceName')]",
165-
"location": "[parameters('location')]",
124+
"location": "[resourceGroup().location]",
166125
"dependsOn": [
167-
"[resourceId('Microsoft.Network/networkSecurityGroups/', parameters('networkSecurityGroupName'))]",
168-
"[resourceId('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
126+
"[resourceId('Microsoft.Network/networkSecurityGroups/', variables('networkSecurityGroupName'))]",
127+
"[resourceId('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]",
169128
"[resourceId('Microsoft.Network/publicIpAddresses/', variables('publicIpAddressName'))]"
170129
],
171130
"properties": {
@@ -184,15 +143,15 @@
184143
}
185144
],
186145
"networkSecurityGroup": {
187-
"id": "[resourceId('Microsoft.Network/networkSecurityGroups',parameters('networkSecurityGroupName'))]"
146+
"id": "[resourceId('Microsoft.Network/networkSecurityGroups',variables('networkSecurityGroupName'))]"
188147
}
189148
}
190149
},
191150
{
192151
"type": "Microsoft.Network/networkSecurityGroups",
193152
"apiVersion": "2020-06-01",
194-
"name": "[parameters('networkSecurityGroupName')]",
195-
"location": "[parameters('location')]",
153+
"name": "[variables('networkSecurityGroupName')]",
154+
"location": "[resourceGroup().location]",
196155
"properties": {
197156
"securityRules": [
198157
{
@@ -214,8 +173,8 @@
214173
{
215174
"type": "Microsoft.Network/virtualNetworks",
216175
"apiVersion": "2020-06-01",
217-
"name": "[parameters('virtualNetworkName')]",
218-
"location": "[parameters('location')]",
176+
"name": "[variables('virtualNetworkName')]",
177+
"location": "[resourceGroup().location]",
219178
"properties": {
220179
"addressSpace": {
221180
"addressPrefixes": [
@@ -224,7 +183,7 @@
224183
},
225184
"subnets": [
226185
{
227-
"name": "[parameters('subnetName')]",
186+
"name": "[variables('subnetName')]",
228187
"properties": {
229188
"addressPrefix": "[variables('subnetAddressPrefix')]",
230189
"privateEndpointNetworkPolicies": "Enabled",
@@ -238,7 +197,7 @@
238197
"type": "Microsoft.Network/publicIpAddresses",
239198
"apiVersion": "2020-06-01",
240199
"name": "[variables('publicIpAddressName')]",
241-
"location": "[parameters('location')]",
200+
"location": "[resourceGroup().location]",
242201
"sku": {
243202
"name": "Basic",
244203
"tier": "Regional"
@@ -247,7 +206,7 @@
247206
"publicIpAllocationMethod": "Dynamic",
248207
"publicIPAddressVersion": "IPv4",
249208
"dnsSettings": {
250-
"domainNameLabel": "[parameters('dnsLabelPrefix')]"
209+
"domainNameLabel": "[variables('dnsLabelPrefix')]"
251210
},
252211
"idleTimeoutInMinutes": 4
253212
}
@@ -256,7 +215,7 @@
256215
"type": "Microsoft.Compute/virtualMachines",
257216
"apiVersion": "2020-06-01",
258217
"name": "[parameters('vmName')]",
259-
"location": "[parameters('location')]",
218+
"location": "[resourceGroup().location]",
260219
"identity": {
261220
"type": "SystemAssigned"
262221
},
@@ -309,7 +268,7 @@
309268
"contentVersion": "1.0.0.0",
310269
"resources": [
311270
{
312-
"name": "[guid(parameters('rbacGuid1'))]",
271+
"name": "[guid(variables('rbacGuid1'))]",
313272
"type": "Microsoft.Authorization/roleAssignments",
314273
"apiVersion": "2017-09-01",
315274
"properties": {
@@ -335,7 +294,7 @@
335294
"contentVersion": "1.0.0.0",
336295
"resources": [
337296
{
338-
"name": "[guid(parameters('rbacGuid2'))]",
297+
"name": "[guid(variables('rbacGuid2'))]",
339298
"type": "Microsoft.Authorization/roleAssignments",
340299
"apiVersion": "2017-09-01",
341300
"properties": {
@@ -361,6 +320,6 @@
361320
"sshCommand": {
362321
"type": "string",
363322
"value": "[concat('ssh ', parameters('adminUsername'), '@', reference(variables('publicIPAddressName')).dnsSettings.fqdn)]"
364-
}
323+
}
365324
}
366-
}
325+
}

0 commit comments

Comments
 (0)