Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
264 lines (263 sloc) 10.4 KB
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"type": "string",
"metadata": {
"description": "Username for the Virtual Machine."
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Password for the Virtual Machine."
}
},
"numberOfInstances": {
"type": "string",
"defaultValue": "1",
"metadata": {
"description": "Number of VMs to deploy."
}
},
"vmName": {
"type": "string",
"metadata": {
"description": "Name Prefix for the Virtual Machine."
}
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_DS3_v2",
"metadata": {
"description": "Size for the Virtual Machine."
}
},
"fileUris": {
"type": "string",
"metadata": {
"description": "URL of the extension package or file"
}
},
"commandToExecute": {
"type": "string",
"defaultValue": "install.sh",
"metadata": {
"description": "Extension bash script command to execute"
}
}
},
"variables": {
"location": "[resourceGroup().location]",
"numberOfInstances": "[int(parameters('numberOfInstances'))]",
"imagePublisher": "microsoft-dsvm",
"imageOffer": "linux-data-science-vm-ubuntu",
"sku": "linuxdsvmubuntu",
"nicName": "[parameters('vmName')]",
"addressPrefix": "10.0.0.0/16",
"subnetName": "Subnet",
"subnetPrefix": "10.0.0.0/24",
"publicIPAddressType": "Dynamic",
"publicIPAddressName": "[parameters('vmName')]",
"vmName": "[parameters('vmName')]",
"vmSize": "[parameters('vmSize')]",
"virtualNetworkName": "[parameters('vmName')]",
"nsgName": "[concat(parameters('vmName'),'-nsg')]",
"nsgId": "[resourceId(resourceGroup().name, 'Microsoft.Network/networkSecurityGroups', variables('nsgName'))]",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
"fileUris": "[parameters('fileUris')]",
"commandToExecute": "[concat('bash ', parameters('commandToExecute'))]"
},
"resources": [
{
"apiVersion": "2018-02-01",
"type": "Microsoft.Network/networkSecurityGroups",
"location": "[variables('location')]",
"name": "[variables('nsgName')]",
"properties": {
"securityRules": [
{
"name": "Allow-SSH-Jupyterhub",
"properties": {
"protocol": "Tcp",
"sourcePortRange": "*",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 100,
"direction": "Inbound",
"sourcePortRanges": [],
"destinationPortRanges": [
"22",
"8000"
],
"destinationPortRange": ""
}
}
]
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[concat(variables('publicIPAddressName'), copyindex())]",
"location": "[variables('location')]",
"copy": {
"name": "publicIPLoop",
"count": "[variables('numberOfInstances')]"
},
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
"dnsSettings": {
"domainNameLabel": "[concat(variables('publicIPAddressName'), copyindex())]"
}
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"location": "[variables('location')]",
"dependsOn": [
"[concat('Microsoft.Network/networkSecurityGroups/', variables('nsgName'))]"
],
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]"
}
}
]
}
},
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat(variables('nicName'), copyindex())]",
"location": "[variables('location')]",
"copy": {
"name": "nicLoop",
"count": "[variables('numberOfInstances')]"
},
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', concat(variables('publicIPAddressName'),copyindex()))]",
"[concat('Microsoft.Network/networkSecurityGroups/', variables('nsgName'))]",
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',concat(variables('publicIPAddressName'),copyindex()))]"
},
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
],
"networkSecurityGroup": {
"id": "[variables('nsgId')]"
}
}
},
{
"apiVersion": "2017-03-30",
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat(variables('vmName'), copyIndex())]",
"location": "[variables('location')]",
"copy": {
"name": "virtualMachineLoop",
"count": "[variables('numberOfInstances')]"
},
"tags": {
"Application": "DataScience"
},
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'), copyindex())]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[variables('vmSize')]"
},
"osProfile": {
"computerName": "[concat(variables('vmName'), copyIndex())]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[variables('sku')]",
"version": "latest"
},
"osDisk": {
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage"
},
"dataDisks": [
{
"managedDisk": {
"storageAccountType": "Standard_LRS"
},
"createOption": "FromImage",
"lun": 0
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat(variables('nicName'), copyindex()))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": false
}
}
},
"resources": [
{
"type": "extensions",
"name": "[variables('vmName')]",
"apiVersion": "2017-03-30",
"location": "[variables('location')]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'),copyindex())]"
],
"properties": {
"publisher": "Microsoft.OSTCExtensions",
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.4",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": "[split(variables('fileUris'), ' ')]",
"commandToExecute": "[variables('commandToExecute')]"
}
}
}
]
}
],
"outputs": {
"firstDataScienceVmUrl": { "type": "string", "value": "[concat('https://ms.portal.azure.com/#resource/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Compute/virtualMachines/', variables('vmName'), '0')]" },
"numInstances": { "type": "string", "value": "[parameters('numberOfInstances')]" }
}
}