Skip to content

Instantly share code, notes, and snippets.

@PixelRobots
Last active November 20, 2017 14:40
Show Gist options
  • Select an option

  • Save PixelRobots/6df277cee34f7e072da16ca3fa625f20 to your computer and use it in GitHub Desktop.

Select an option

Save PixelRobots/6df277cee34f7e072da16ca3fa625f20 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": {
"adminUsername": {
"type": "string",
"metadata": {
"description": "The name of the administrator account of the new VM and domain"
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "The password for the administrator account of the new VM and domain"
}
},
"domainName": {
"type": "string",
"metadata": {
"description": "The FQDN of the Active Directory Domain to be created"
}
},
"dnsPrefix": {
"type": "string",
"metadata": {
"description": "The DNS prefix for the public IP address used by the Load Balancer"
}
},
"_artifactsLocation": {
"type": "string",
"metadata": {
"description": "The location of resources, such as templates and DSC modules, that the template depends on"
},
"defaultValue": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/active-directory-new-domain"
},
"_artifactsLocationSasToken": {
"type": "securestring",
"metadata": {
"description": "Auto-generated token to access _artifactsLocation"
},
"defaultValue": ""
}
},
"variables": {
"virtualNetworkName": "adVNET",
"virtualNetworkAddressRange": "172.17.10.0/24",
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'adsa')]",
"adLBFE": "LBFE",
"adLBBE": "LBBE",
"adRDPNAT": "adRDP",
"adNicName": "adNic",
"adNicIPAddress": "172.17.10.4",
"adVMName": "PIXEL-DC01",
"adSubnetName": "adSubnet",
"adSubnetAddressPrefix": "172.17.10.0/26",
"publicIPAddressName": "adPublicIP",
"adAvailabilitySetName": "adAvailabiltySet",
"adLBName": "adLoadBalancer"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2016-01-01",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard_LRS"
},
"kind": "Storage",
"properties": {}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIPAddressName')]",
"apiVersion": "2016-03-30",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"dnsSettings": {
"domainNameLabel": "[parameters('dnsPrefix')]"
}
}
},
{
"type": "Microsoft.Compute/availabilitySets",
"name": "[variables('adAvailabilitySetName')]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"properties": {}
},
{
"type": "Microsoft.Resources/deployments",
"name": "VNet",
"apiVersion": "2016-02-01",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(parameters('_artifactsLocation'), '/nestedtemplates/vnet.json', parameters('_artifactsLocationSasToken'))]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"virtualNetworkName": {
"value": "[variables('virtualNetworkName')]"
},
"virtualNetworkAddressRange": {
"value": "[variables('virtualNetworkAddressRange')]"
},
"subnetName": {
"value": "[variables('adSubnetName')]"
},
"subnetRange": {
"value": "[variables('adSubnetAddressPrefix')]"
}
}
}
},
{
"type": "Microsoft.Network/loadBalancers",
"name": "[variables('adLBName')]",
"apiVersion": "2016-03-30",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
],
"properties": {
"frontendIPConfigurations": [
{
"name": "[variables('adLBFE')]",
"properties": {
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
}
}
}
],
"backendAddressPools": [
{
"name": "[variables('adLBBE')]"
}
],
"inboundNatRules": [
{
"name": "[variables('adRDPNAT')]",
"properties": {
"frontendIPConfiguration": {
"id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('adLBName'), variables('adLBFE'))]"
},
"protocol": "tcp",
"frontendPort": 3389,
"backendPort": 3389,
"enableFloatingIP": false
}
}
]
}
},
{
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('adNicName')]",
"apiVersion": "2016-03-30",
"location": "[resourceGroup().location]",
"dependsOn": [
"Microsoft.Resources/deployments/VNet",
"[resourceId('Microsoft.Network/loadBalancers', variables('adLBName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Static",
"privateIPAddress": "[variables('adNicIPAddress')]",
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('adSubnetName'))]"
},
"loadBalancerBackendAddressPools": [
{
"id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('adLBName'), variables('adLBBE'))]"
}
],
"loadBalancerInboundNatRules": [
{
"id": "[resourceId('Microsoft.Network/loadBalancers/inboundNatRules', variables('adLBName'), variables('adRDPNAT'))]"
}
]
}
}
]
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('adVMName')]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"[resourceId('Microsoft.Network/networkInterfaces', variables('adNicName'))]",
"[resourceId('Microsoft.Compute/availabilitySets', variables('adAvailabilitySetName'))]",
"[resourceId('Microsoft.Network/loadBalancers', variables('adLBName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "Standard_D2_v2"
},
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets', variables('adAvailabilitySetName'))]"
},
"osProfile": {
"computerName": "[variables('adVMName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-Datacenter",
"version": "latest"
},
"osDisk": {
"name": "osdisk",
"vhd": {
"uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))).primaryEndpoints.blob, 'vhds/', variables('adVMName'), '-os-disk.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
},
"dataDisks": [
{
"vhd": {
"uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))).primaryEndpoints.blob, 'vhds/', variables('adVMName'), '-data-disk.vhd')]"
},
"name": "[concat(variables('adVMName'), '-data-disk')]",
"caching": "None",
"createOption": "Empty",
"diskSizeGB": "100",
"lun": 0
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('adNicName'))]"
}
]
}
},
"resources": [
{
"type": "extensions",
"name": "CreateADForest",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines', variables('adVMName'))]"
],
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.19",
"autoUpgradeMinorVersion": true,
"settings": {
"ModulesUrl": "[concat(parameters('_artifactsLocation'), '/DSC/CreateADPDC.zip', parameters('_artifactsLocationSasToken'))]",
"ConfigurationFunction": "CreateADPDC.ps1\\CreateADPDC",
"Properties": {
"DomainName": "[parameters('domainName')]",
"AdminCreds": {
"UserName": "[parameters('adminUsername')]",
"Password": "PrivateSettingsRef:AdminPassword"
}
}
},
"protectedSettings": {
"Items": {
"AdminPassword": "[parameters('adminPassword')]"
}
}
}
}
]
},
{
"type": "Microsoft.Resources/deployments",
"name": "UpdateVNetDNS",
"apiVersion": "2016-02-01",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines/extensions', variables('adVMName'), 'CreateADForest')]"
],
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(parameters('_artifactsLocation'), '/nestedtemplates/vnet-with-dns-server.json', parameters('_artifactsLocationSasToken'))]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"virtualNetworkName": {
"value": "[variables('virtualNetworkName')]"
},
"virtualNetworkAddressRange": {
"value": "[variables('virtualNetworkAddressRange')]"
},
"subnetName": {
"value": "[variables('adSubnetName')]"
},
"subnetRange": {
"value": "[variables('adSubnetAddressPrefix')]"
},
"DNSServerAddress": {
"value": [
"[variables('adNicIPAddress')]"
]
}
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment