{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "metadata": { "_generator": { "name": "bicep", "version": "0.13.1.58284", "templateHash": "17567019607531788589" } }, "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" } }, "vmSize": { "type": "string", "defaultValue": "Standard_D2s_v3", "metadata": { "description": "Size of the VM for the controller" } }, "_artifactsLocation": { "type": "string", "defaultValue": "[deployment().properties.templateLink.uri]", "metadata": { "description": "The location of resources, such as templates and DSC modules, that the template depends on" } }, "_artifactsLocationSasToken": { "type": "secureString", "defaultValue": "", "metadata": { "description": "Auto-generated token to access _artifactsLocation. Leave it blank unless you need to provide your own value." } }, "location": { "type": "string", "defaultValue": "[resourceGroup().location]", "metadata": { "description": "Location for all resources." } }, "virtualMachineName": { "type": "string", "defaultValue": "adVM", "maxLength": 15, "metadata": { "description": "Virtual machine name." } }, "virtualNetworkName": { "type": "string", "defaultValue": "adVNET", "metadata": { "description": "Virtual network name." } }, "virtualNetworkAddressRange": { "type": "string", "defaultValue": "10.0.0.0/16", "metadata": { "description": "Virtual network address range." } }, "loadBalancerFrontEndIPName": { "type": "string", "defaultValue": "LBFE", "metadata": { "description": "Load balancer front end IP address name." } }, "backendAddressPoolName": { "type": "string", "defaultValue": "LBBE", "metadata": { "description": "Backend address pool name." } }, "inboundNatRulesName": { "type": "string", "defaultValue": "adRDP", "metadata": { "description": "Inbound NAT rules name." } }, "networkInterfaceName": { "type": "string", "defaultValue": "adNic", "metadata": { "description": "Network interface name." } }, "privateIPAddress": { "type": "string", "defaultValue": "10.0.0.4", "metadata": { "description": "Private IP address." } }, "subnetName": { "type": "string", "defaultValue": "adSubnet", "metadata": { "description": "Subnet name." } }, "subnetRange": { "type": "string", "defaultValue": "10.0.0.0/24", "metadata": { "description": "Subnet IP range." } }, "publicIPAddressName": { "type": "string", "defaultValue": "adPublicIP", "metadata": { "description": "Subnet IP range." } }, "availabilitySetName": { "type": "string", "defaultValue": "adAvailabiltySet", "metadata": { "description": "Availability set name." } }, "loadBalancerName": { "type": "string", "defaultValue": "adLoadBalancer", "metadata": { "description": "Load balancer name." } } }, "resources": [ { "type": "Microsoft.Network/publicIPAddresses", "apiVersion": "2022-07-01", "name": "[parameters('publicIPAddressName')]", "location": "[parameters('location')]", "properties": { "publicIPAllocationMethod": "Static", "dnsSettings": { "domainNameLabel": "[parameters('dnsPrefix')]" } } }, { "type": "Microsoft.Compute/availabilitySets", "apiVersion": "2022-08-01", "name": "[parameters('availabilitySetName')]", "location": "[parameters('location')]", "properties": { "platformUpdateDomainCount": 20, "platformFaultDomainCount": 2 }, "sku": { "name": "Aligned" } }, { "type": "Microsoft.Network/loadBalancers", "apiVersion": "2022-07-01", "name": "[parameters('loadBalancerName')]", "location": "[parameters('location')]", "properties": { "frontendIPConfigurations": [ { "name": "[parameters('loadBalancerFrontEndIPName')]", "properties": { "publicIPAddress": { "id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddressName'))]" } } } ], "backendAddressPools": [ { "name": "[parameters('backendAddressPoolName')]" } ], "inboundNatRules": [ { "name": "[parameters('inboundNatRulesName')]", "properties": { "frontendIPConfiguration": { "id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', parameters('loadBalancerName'), parameters('loadBalancerFrontEndIPName'))]" }, "protocol": "Tcp", "frontendPort": 3389, "backendPort": 3389, "enableFloatingIP": false } } ] }, "dependsOn": [ "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddressName'))]" ] }, { "type": "Microsoft.Network/networkInterfaces", "apiVersion": "2022-07-01", "name": "[parameters('networkInterfaceName')]", "location": "[parameters('location')]", "properties": { "ipConfigurations": [ { "name": "ipconfig1", "properties": { "privateIPAllocationMethod": "Static", "privateIPAddress": "[parameters('privateIPAddress')]", "subnet": { "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworkName'), parameters('subnetName'))]" }, "loadBalancerBackendAddressPools": [ { "id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', parameters('loadBalancerName'), parameters('backendAddressPoolName'))]" } ], "loadBalancerInboundNatRules": [ { "id": "[resourceId('Microsoft.Network/loadBalancers/inboundNatRules', parameters('loadBalancerName'), parameters('inboundNatRulesName'))]" } ] } } ] }, "dependsOn": [ "[resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancerName'))]", "[resourceId('Microsoft.Resources/deployments', 'VNet')]" ] }, { "type": "Microsoft.Compute/virtualMachines", "apiVersion": "2022-08-01", "name": "[parameters('virtualMachineName')]", "location": "[parameters('location')]", "properties": { "hardwareProfile": { "vmSize": "[parameters('vmSize')]" }, "availabilitySet": { "id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('availabilitySetName'))]" }, "osProfile": { "computerName": "[parameters('virtualMachineName')]", "adminUsername": "[parameters('adminUsername')]", "adminPassword": "[parameters('adminPassword')]" }, "storageProfile": { "imageReference": { "publisher": "MicrosoftWindowsServer", "offer": "WindowsServer", "sku": "2019-Datacenter", "version": "latest" }, "osDisk": { "name": "[format('{0}_OSDisk', parameters('virtualMachineName'))]", "caching": "ReadOnly", "createOption": "FromImage", "managedDisk": { "storageAccountType": "StandardSSD_LRS" } }, "dataDisks": [ { "name": "[format('{0}_DataDisk', parameters('virtualMachineName'))]", "caching": "ReadWrite", "createOption": "Empty", "diskSizeGB": 20, "managedDisk": { "storageAccountType": "StandardSSD_LRS" }, "lun": 0 } ] }, "networkProfile": { "networkInterfaces": [ { "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]" } ] } }, "dependsOn": [ "[resourceId('Microsoft.Compute/availabilitySets', parameters('availabilitySetName'))]", "[resourceId('Microsoft.Network/loadBalancers', parameters('loadBalancerName'))]", "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]" ] }, { "type": "Microsoft.Compute/virtualMachines/extensions", "apiVersion": "2022-08-01", "name": "[format('{0}/{1}', parameters('virtualMachineName'), 'CreateADForest')]", "location": "[parameters('location')]", "properties": { "publisher": "Microsoft.Powershell", "type": "DSC", "typeHandlerVersion": "2.19", "autoUpgradeMinorVersion": true, "settings": { "ModulesUrl": "[uri(parameters('_artifactsLocation'), format('DSC/CreateADPDC.zip{0}', parameters('_artifactsLocationSasToken')))]", "ConfigurationFunction": "CreateADPDC.ps1\\CreateADPDC", "Properties": { "DomainName": "[parameters('domainName')]", "AdminCreds": { "UserName": "[parameters('adminUsername')]", "Password": "PrivateSettingsRef:AdminPassword" } } }, "protectedSettings": { "Items": { "AdminPassword": "[parameters('adminPassword')]" } } }, "dependsOn": [ "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]" ] }, { "type": "Microsoft.Resources/deployments", "apiVersion": "2020-10-01", "name": "VNet", "properties": { "expressionEvaluationOptions": { "scope": "inner" }, "mode": "Incremental", "parameters": { "virtualNetworkName": { "value": "[parameters('virtualNetworkName')]" }, "virtualNetworkAddressRange": { "value": "[parameters('virtualNetworkAddressRange')]" }, "subnetName": { "value": "[parameters('subnetName')]" }, "subnetRange": { "value": "[parameters('subnetRange')]" }, "location": { "value": "[parameters('location')]" } }, "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "metadata": { "_generator": { "name": "bicep", "version": "0.13.1.58284", "templateHash": "7676624414886455368" } }, "parameters": { "virtualNetworkName": { "type": "string", "metadata": { "description": "The name of the Virtual Network to Create" } }, "virtualNetworkAddressRange": { "type": "string", "metadata": { "description": "The address range of the new VNET in CIDR format" } }, "subnetName": { "type": "string", "metadata": { "description": "The name of the subnet created in the new VNET" } }, "subnetRange": { "type": "string", "metadata": { "description": "The address range of the subnet created in the new VNET" } }, "location": { "type": "string", "metadata": { "description": "Location for all resources." } } }, "resources": [ { "type": "Microsoft.Network/virtualNetworks", "apiVersion": "2022-07-01", "name": "[parameters('virtualNetworkName')]", "location": "[parameters('location')]", "properties": { "addressSpace": { "addressPrefixes": [ "[parameters('virtualNetworkAddressRange')]" ] }, "subnets": [ { "name": "[parameters('subnetName')]", "properties": { "addressPrefix": "[parameters('subnetRange')]" } } ] } } ] } } }, { "type": "Microsoft.Resources/deployments", "apiVersion": "2020-10-01", "name": "UpdateVNetDNS", "properties": { "expressionEvaluationOptions": { "scope": "inner" }, "mode": "Incremental", "parameters": { "virtualNetworkName": { "value": "[parameters('virtualNetworkName')]" }, "virtualNetworkAddressRange": { "value": "[parameters('virtualNetworkAddressRange')]" }, "subnetName": { "value": "[parameters('subnetName')]" }, "subnetRange": { "value": "[parameters('subnetRange')]" }, "DNSServerAddress": { "value": [ "[parameters('privateIPAddress')]" ] }, "location": { "value": "[parameters('location')]" } }, "template": { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "metadata": { "_generator": { "name": "bicep", "version": "0.13.1.58284", "templateHash": "12019049826642862479" } }, "parameters": { "virtualNetworkName": { "type": "string", "metadata": { "description": "The name of the Virtual Network to Create" } }, "virtualNetworkAddressRange": { "type": "string", "metadata": { "description": "The address range of the new VNET in CIDR format" } }, "subnetName": { "type": "string", "metadata": { "description": "The name of the subnet created in the new VNET" } }, "subnetRange": { "type": "string", "metadata": { "description": "The address range of the subnet created in the new VNET" } }, "DNSServerAddress": { "type": "array", "metadata": { "description": "The DNS address(es) of the DNS Server(s) used by the VNET" } }, "location": { "type": "string", "metadata": { "description": "Location for all resources." } } }, "resources": [ { "type": "Microsoft.Network/virtualNetworks", "apiVersion": "2022-07-01", "name": "[parameters('virtualNetworkName')]", "location": "[parameters('location')]", "properties": { "addressSpace": { "addressPrefixes": [ "[parameters('virtualNetworkAddressRange')]" ] }, "dhcpOptions": { "dnsServers": "[parameters('DNSServerAddress')]" }, "subnets": [ { "name": "[parameters('subnetName')]", "properties": { "addressPrefix": "[parameters('subnetRange')]" } } ] } } ] } }, "dependsOn": [ "[resourceId('Microsoft.Compute/virtualMachines/extensions', parameters('virtualMachineName'), 'CreateADForest')]" ] } ] }