Skip to content

Instantly share code, notes, and snippets.

@tylerd
Last active June 3, 2019 18:16
Show Gist options
  • Save tylerd/a333334290703e2269f19b88b4889f0e to your computer and use it in GitHub Desktop.
Save tylerd/a333334290703e2269f19b88b4889f0e to your computer and use it in GitHub Desktop.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"NamePrefix": {
"defaultValue": "Dev-VM",
"type": "string"
},
"VMSize": {
"defaultValue": "Standard_D4s_v3",
"type": "string"
},
"AdminUsername": {
"defaultValue": "tylerd",
"type": "string"
},
"AdminPassword": {
"type": "securestring"
},
"VnetAddressRange": {
"defaultValue": "10.111.0.0/24",
"type": "string"
}
},
"variables": {
"vmName":"[parameters('namePrefix')]",
"vmId":"[resourceId('Microsoft.Compute/virtualMachines', variables('vmName'))]",
"location":"[resourceGroup().location]",
"osDiskName":"[concat(variables('vmName'),'-osdisk')]",
"nicName":"[concat(variables('vmName'),'-nic')]",
"nicId": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]",
"pipName":"[concat(variables('vmName'),'-pip')]",
"pipId":"[resourceId('Microsoft.Network/publicIPAddresses', variables('pipName'))]",
"vnetName":"[concat(variables('vmName'),'-vnet')]",
"vnetId":"[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]",
"subnetName":"default",
"subnetId":"[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'), variables('subnetName'))]",
"vnetAddressRange":"[parameters('VnetAddressRange')]",
"nsgName":"[concat(variables('vmName'),'-nsg')]",
"nsgId":"[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]",
"scheduleName":"[concat('shutdown-computevm-',parameters('NamePrefix'))]"
},
"resources": [
{
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('vmName')]",
"apiVersion": "2017-12-01",
"location": "[variables('location')]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('VMSize')]"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftVisualStudio",
"offer": "VisualStudio2019",
"sku": "vs-2019-ent-win10-n",
"version": "latest"
},
"osDisk": {
"osType": "Windows",
"name": "[variables('osDiskName')]",
"createOption": "FromImage",
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Premium_LRS"
},
"diskSizeGB": 127
},
"dataDisks": []
},
"osProfile": {
"computerName": "[variables('vmName')]",
"adminUsername": "[parameters('AdminUsername')]",
"adminPassword": "[parameters('AdminPassword')]",
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[variables('nicId')]"
}
]
}
},
"dependsOn": [
"[variables('nicId')]"
]
},
{
"type": "microsoft.devtestlab/schedules",
"name": "[variables('scheduleName')]",
"apiVersion": "2016-05-15",
"location": "[variables('location')]",
"properties": {
"status": "Enabled",
"taskType": "ComputeVmShutdownTask",
"dailyRecurrence": {
"time": "1900"
},
"timeZoneId": "Central Standard Time",
"targetResourceId": "[variables('vmId')]"
},
"dependsOn": [
"[variables('vmId')]"
]
},
{
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('nicName')]",
"apiVersion": "2018-02-01",
"location": "[variables('location')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[variables('pipId')]"
},
"subnet": {
"id": "[variables('subnetId')]"
},
"primary": true,
"privateIPAddressVersion": "IPv4"
}
}
],
"networkSecurityGroup": {
"id": "[variables('nsgId')]"
},
"primary": true
},
"dependsOn": [
"[variables('pipId')]",
"[variables('vnetId')]",
"[variables('nsgId')]"
]
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"name": "[variables('nsgName')]",
"apiVersion": "2018-02-01",
"location": "[variables('location')]",
"properties": {
"securityRules": [
{
"name": "allow-rdp",
"properties": {
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "3389",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 1000,
"direction": "Inbound"
}
}
]
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"sku": {
"name": "Basic",
"tier": "Regional"
},
"name": "[variables('pipName')]",
"apiVersion": "2018-02-01",
"location": "[variables('location')]",
"properties": {
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Dynamic",
"idleTimeoutInMinutes": 4
}
},
{
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('vnetName')]",
"apiVersion": "2018-02-01",
"location": "[variables('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('vnetAddressRange')]"
]
},
"subnets": [
{
"name": "default",
"properties": {
"addressPrefix": "[variables('vnetAddressRange')]"
}
}
]
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'),'/CustomScriptExtension')]",
"apiVersion": "2015-06-15",
"location": "[variables('location')]",
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.8",
"autoUpgradeMinorVersion": "true",
"settings": {
"commandToExecute": "powershell -ExecutionPolicy Unrestricted iex ((New-Object System.Net.WebClient).DownloadString('https://boxstarter.org/bootstrapper.ps1')); get-boxstarter -Force; "
}
},
"dependsOn": [
"[variables('vmId')]"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment