Skip to content

Instantly share code, notes, and snippets.

@SidneyAndrewsOpsgility
Last active March 2, 2021 19:29
Show Gist options
  • Save SidneyAndrewsOpsgility/db3935cb207748e998e8 to your computer and use it in GitHub Desktop.
Save SidneyAndrewsOpsgility/db3935cb207748e998e8 to your computer and use it in GitHub Desktop.
Azure Resource Manager Template to create a Development VM using PowerShell Desired State Configuration (DSC) and Web Platform Installer (WPI)
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"suffix": {
"type": "string",
"metadata": {
"description": "This should be a globally unique suffix. It is recommended to use the first 5 letters of your name and a random 2 digit number to create a 7 character unique suffix"
}
},
"location": {
"type": "string",
"allowedValues": [ "East US", "West US", "West Europe", "East Asia", "South East Asia" ],
"metadata": {
"description": "This is the location where the resources will be deployed"
}
}
},
"variables": {
"adminUsername": "Student",
"adminPassword": "AzurePa$$w0rd",
"windowsOSVersion": "2012-R2-Datacenter",
"imagePublisher": "MicrosoftWindowsServer",
"imageOffer": "WindowsServer",
"osDiskName": "vm20532-OS",
"dataDiskName": "vm20532-AllFiles",
"dataDiskSizeGb": "6",
"nicName": "nic20532",
"addressPrefix": "10.0.0.0/16",
"subnetName": "Dev",
"subnetPrefix": "10.0.0.0/24",
"storageAccountType": "Standard_LRS",
"publicIPAddressName": "ip20532",
"publicIPAddressType": "Dynamic",
"vmStorageAccountContainerName": "vhds",
"vmSize": "Standard_A3",
"virtualNetworkName": "dev20532",
"vmExtensionName": "DSCExtension",
"dscModulesUrl": "https://gist.github.com/SidneyAndrewsOpsgility/db3935cb207748e998e8/raw/1335c906f681eac77b113d0058af8a5061af9bde/AzureDev.zip",
"dscConfigurationFunction": "AzureDev.ps1\\AzureDev",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
"storageAccountName": "[concat('stor20532', parameters('suffix'))]",
"dnsNameForPublicIP": "[concat('vm20532', parameters('suffix'))]",
"vmName": "[variables('dnsNameForPublicIP')]"
},
"resources": [
{
"apiVersion": "2015-05-01-preview",
"location": "[parameters('location')]",
"name": "[variables('storageAccountName')]",
"properties": {
"accountType": "[variables('storageAccountType')]"
},
"tags": {
"displayName": "StorageAccount"
},
"type": "Microsoft.Storage/storageAccounts"
},
{
"apiVersion": "2015-05-01-preview",
"location": "[parameters('location')]",
"name": "[variables('publicIPAddressName')]",
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
"dnsSettings": {
"domainNameLabel": "[variables('dnsNameForPublicIP')]"
}
},
"tags": {
"displayName": "PublicIPAddress"
},
"type": "Microsoft.Network/publicIPAddresses"
},
{
"apiVersion": "2015-05-01-preview",
"location": "[parameters('location')]",
"name": "[variables('virtualNetworkName')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]"
}
}
]
},
"tags": {
"displayName": "VirtualNetwork"
},
"type": "Microsoft.Network/virtualNetworks"
},
{
"apiVersion": "2015-05-01-preview",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
],
"location": "[parameters('location')]",
"name": "[variables('nicName')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
},
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
},
"tags": {
"displayName": "NetworkInterface"
},
"type": "Microsoft.Network/networkInterfaces"
},
{
"apiVersion": "2015-05-01-preview",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
],
"location": "[parameters('location')]",
"name": "[variables('vmName')]",
"properties": {
"hardwareProfile": {
"vmSize": "[variables('vmSize')]"
},
"osProfile": {
"computername": "[variables('vmName')]",
"adminUsername": "[variables('adminUsername')]",
"adminPassword": "[variables('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[variables('windowsOSVersion')]",
"version": "latest"
},
"dataDisks": [
{
"name": "[variables('dataDiskName')]",
"diskSizeGB": "[variables('dataDiskSizeGb')]",
"lun": 0,
"vhd": {
"uri": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('dataDiskName'),'.vhd')]"
},
"createOption": "Empty"
}
],
"osDisk": {
"name": "[variables('osDiskName')]",
"vhd": {
"uri": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('osDiskName'),'.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
}
]
}
},
"tags": {
"displayName": "VirtualMachine"
},
"type": "Microsoft.Compute/virtualMachines"
},
{
"apiVersion": "2015-05-01-preview",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
],
"location": "[parameters('location')]",
"name": "[concat(variables('vmName'), '/', variables('vmExtensionName'))]",
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": "true",
"settings": {
"ModulesUrl": "[variables('dscModulesUrl')]",
"SasToken": "",
"ConfigurationFunction": "[variables('dscConfigurationFunction')]",
"Properties": {
"MachineName": "[variables('vmName')]"
}
},
"protectedSettings": null
},
"type": "Microsoft.Compute/virtualMachines/extensions"
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"suffix": {
"value": "ExampleSuffix"
},
"location": {
"value": "West US"
}
}
}
Configuration AzureDev
{
Node localhost
{
#Install IIS
WindowsFeature IIS
{
Ensure = “Present”
Name = “Web-Server”
}
#Install ASP.NET 4.5
WindowsFeature ASP
{
Ensure = “Present”
Name = “Web-Asp-Net45”
}
#Install IIS Management Console
WindowsFeature WebServerManagementConsole
{
Ensure = "Present"
Name = "Web-Mgmt-Console"
}
#Install Web Platform Installer
Package WebPi_Installation
{
Ensure = "Present"
Name = "Microsoft Web Platform Installer 5.0"
Path = Join-Path $PSScriptRoot wpilauncher.exe
ProductId = '4D84C195-86F0-4B34-8FDE-4A17EB41306A'
Arguments = ''
}
#Install Azure PowerShell
Package AzurePowerShell_Installation
{
Ensure = "Present"
Name = "Azure PowerShell"
Path = "$env:ProgramFiles\Microsoft\Web Platform Installer\WebPiCmd-x64.exe"
ProductId = ''
Arguments = "/install /products:WindowsAzurePowerShell /accepteula"
DependsOn = @("[Package]WebPi_Installation")
}
#Install Visual Studio 2013 & Azure SDK 2.6
Package VisualStudio_Installation
{
Ensure = "Present"
Name = "Visual Studio 2013 Community Edition"
Path = "$env:ProgramFiles\Microsoft\Web Platform Installer\WebPiCmd-x64.exe"
ProductId = ''
Arguments = "/install /products:vs2013communityazurepack.2.6 /accepteula /forcereboot"
DependsOn = @("[Package]WebPi_Installation")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment