Created
February 11, 2021 23:23
-
-
Save krnese/c79f36992528033eabade8d110a03c95 to your computer and use it in GitHub Desktop.
VMSS into existing vNet with IIS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"vmSku": { | |
"type": "string", | |
"defaultValue": "Standard_A1_v2", | |
"metadata": { | |
"description": "Size of VMs in the VM Scale Set." | |
} | |
}, | |
"windowsOSVersion": { | |
"type": "string", | |
"defaultValue": "2019-Datacenter", | |
"allowedValues": [ | |
"2008-R2-SP1", | |
"2012-Datacenter", | |
"2012-R2-Datacenter", | |
"2016-Datacenter", | |
"2019-Datacenter" | |
], | |
"metadata": { | |
"description": "The Windows version for the VM. This will pick a fully patched image of this given Windows version. Allowed values: 2008-R2-SP1, 2012-Datacenter, 2012-R2-Datacenter & 2016-Datacenter, 2019-Datacenter." | |
} | |
}, | |
"vmssName": { | |
"type": "string", | |
"minLength": 3, | |
"maxLength": 61, | |
"metadata": { | |
"description": "String used as a base for naming resources. Must be 3-61 characters in length and globally unique across Azure. A hash is prepended to this string for some resources, and resource-specific information is appended." | |
} | |
}, | |
"instanceCount": { | |
"type": "int", | |
"defaultValue": 3, | |
"minValue": 1, | |
"maxValue": 100, | |
"metadata": { | |
"description": "Number of VM instances (100 or less)." | |
} | |
}, | |
"singlePlacementGroup": { | |
"type": "bool", | |
"defaultValue": true, | |
"metadata": { | |
"description": "When true this limits the scale set to a single placement group, of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be modified to false. However, if singlePlacementGroup is false, it may not be modified to true." | |
} | |
}, | |
"adminUsername": { | |
"type": "string", | |
"defaultValue": "vmssadmin", | |
"metadata": { | |
"description": "Admin username on all VMs." | |
} | |
}, | |
"adminPassword": { | |
"type": "securestring", | |
"metadata": { | |
"description": "Admin password on all VMs." | |
} | |
}, | |
"_artifactsLocation": { | |
"type": "string", | |
"defaultValue": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/201-vmss-windows-webapp-dsc-autoscale/", | |
"metadata": { | |
"description": "The base URI where artifacts required by this template are located. For example, if stored on a public GitHub repo, you'd use the following URI: https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/201-vmss-windows-webapp-dsc-autoscale/." | |
} | |
}, | |
"_artifactsLocationSasToken": { | |
"type": "securestring", | |
"defaultValue": "", | |
"metadata": { | |
"description": "The sasToken required to access _artifactsLocation. If your artifacts are stored on a public repo or public storage account you can leave this blank." | |
} | |
}, | |
"powershelldscZip": { | |
"type": "string", | |
"defaultValue": "DSC/InstallIIS.zip", | |
"metadata": { | |
"description": "Location of the PowerShell DSC zip file relative to the URI specified in the _artifactsLocation, i.e. DSC/IISInstall.ps1.zip" | |
} | |
}, | |
"webDeployPackage": { | |
"type": "string", | |
"defaultValue": "WebDeploy/DefaultASPWebApp.v1.0.zip", | |
"metadata": { | |
"description": "Location of the of the WebDeploy package zip file relative to the URI specified in _artifactsLocation, i.e. WebDeploy/DefaultASPWebApp.v1.0.zip" | |
} | |
}, | |
"powershelldscUpdateTagVersion": { | |
"type": "string", | |
"defaultValue": "1.0", | |
"metadata": { | |
"description": "Version number of the DSC deployment. Changing this value on subsequent deployments will trigger the extension to run." | |
} | |
}, | |
"location": { | |
"type": "string", | |
"defaultValue": "[resourceGroup().location]", | |
"metadata": { | |
"description": "Location for all resources." | |
} | |
}, | |
"platformFaultDomainCount": { | |
"type": "int", | |
"defaultValue": 1, | |
"metadata": { | |
"description": "Fault Domain count for each placement group." | |
} | |
}, | |
"vNetRgName": { | |
"type": "string", | |
"metadata": { | |
"description": "Provide the name of the Rg." | |
} | |
}, | |
"vNetName": { | |
"type": "string" | |
}, | |
"subnetName": { | |
"type": "string" | |
} | |
}, | |
"variables": { | |
"namingInfix": "[toLower(substring(concat(parameters('vmssName'), uniqueString(resourceGroup().id)), 0, 9))]", | |
"loadBalancerName": "[concat(variables('namingInfix'), 'lb')]", | |
"lbProbeID": "[resourceId('Microsoft.Network/loadBalancers/probes',variables('loadBalancerName'), 'tcpProbe')]", | |
"natPoolName": "[concat(variables('namingInfix'), 'natpool')]", | |
"bePoolName": "[concat(variables('namingInfix'), 'bepool')]", | |
"lbPoolID": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools',variables('loadBalancerName'),variables('bePoolName'))]", | |
"natStartPort": 50000, | |
"natEndPort": 50119, | |
"natBackendPort": 3389, | |
"nicName": "[concat(variables('namingInfix'), 'nic')]", | |
"ipConfigName": "[concat(variables('namingInfix'), 'ipconfig')]", | |
"frontEndIPConfigID": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations',variables('loadBalancerName'),'loadBalancerFrontEnd')]", | |
"osType": { | |
"publisher": "MicrosoftWindowsServer", | |
"offer": "WindowsServer", | |
"sku": "[parameters('windowsOSVersion')]", | |
"version": "latest" | |
}, | |
"imageReference": "[variables('osType')]", | |
"webDeployPackageFullPath": "[uri(parameters('_artifactsLocation'), concat(parameters('webDeployPackage'), parameters('_artifactsLocationSasToken')))]", | |
"powershelldscZipFullPath": "[uri(parameters('_artifactsLocation'), concat(parameters('powershelldscZip'), parameters('_artifactsLocationSasToken')))]" | |
}, | |
"resources": [ | |
{ | |
"type": "Microsoft.Network/loadBalancers", | |
"apiVersion": "2020-06-01", | |
"name": "[variables('loadBalancerName')]", | |
"location": "[parameters('location')]", | |
"dependsOn": [ | |
], | |
"properties": { | |
"frontendIPConfigurations": [ | |
{ | |
"name": "LoadBalancerFrontEnd", | |
"properties": { | |
"subnet": { | |
"id": "[concat(subscription().id, '/resourceGroups/', parameters('vNetRgName'), '/providers/Microsoft.Network/virtualNetworks/', parameters('vNetName'), '/subnets/', parameters('subnetName'))]" | |
} | |
} | |
} | |
], | |
"backendAddressPools": [ | |
{ | |
"name": "[variables('bePoolName')]" | |
} | |
], | |
"inboundNatPools": [ | |
{ | |
"name": "[variables('natPoolName')]", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[variables('frontEndIPConfigID')]" | |
}, | |
"protocol": "Tcp", | |
"frontendPortRangeStart": "[variables('natStartPort')]", | |
"frontendPortRangeEnd": "[variables('natEndPort')]", | |
"backendPort": "[variables('natBackendPort')]" | |
} | |
} | |
], | |
"loadBalancingRules": [ | |
{ | |
"name": "LBRule", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[variables('frontEndIPConfigID')]" | |
}, | |
"backendAddressPool": { | |
"id": "[variables('lbPoolID')]" | |
}, | |
"protocol": "Tcp", | |
"frontendPort": 80, | |
"backendPort": 80, | |
"enableFloatingIP": false, | |
"idleTimeoutInMinutes": 5, | |
"probe": { | |
"id": "[variables('lbProbeID')]" | |
} | |
} | |
} | |
], | |
"probes": [ | |
{ | |
"name": "tcpProbe", | |
"properties": { | |
"protocol": "Tcp", | |
"port": 80, | |
"intervalInSeconds": 5, | |
"numberOfProbes": 2 | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"type": "Microsoft.Compute/virtualMachineScaleSets", | |
"apiVersion": "2020-06-01", | |
"name": "[variables('namingInfix')]", | |
"location": "[parameters('location')]", | |
"sku": { | |
"name": "[parameters('vmSku')]", | |
"tier": "Standard", | |
"capacity": "[parameters('instanceCount')]" | |
}, | |
"dependsOn": [ | |
"[resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))]" | |
], | |
"properties": { | |
"overprovision": true, | |
"upgradePolicy": { | |
"mode": "Automatic" | |
}, | |
"singlePlacementGroup": "[parameters('singlePlacementGroup')]", | |
"platformFaultDomainCount": "[parameters('platformFaultDomainCount')]", | |
"virtualMachineProfile": { | |
"storageProfile": { | |
"osDisk": { | |
"caching": "ReadWrite", | |
"createOption": "FromImage" | |
}, | |
"imageReference": "[variables('imageReference')]" | |
}, | |
"osProfile": { | |
"computerNamePrefix": "[variables('namingInfix')]", | |
"adminUsername": "[parameters('adminUsername')]", | |
"adminPassword": "[parameters('adminPassword')]" | |
}, | |
"networkProfile": { | |
"networkInterfaceConfigurations": [ | |
{ | |
"name": "[variables('nicName')]", | |
"properties": { | |
"primary": true, | |
"ipConfigurations": [ | |
{ | |
"name": "[variables('ipConfigName')]", | |
"properties": { | |
"subnet": { | |
"id": "[concat(subscription().id, '/resourceGroups/', parameters('vNetRgName'), '/providers/Microsoft.Network/virtualNetworks/', parameters('vNetName'), '/subnets/', parameters('subnetName'))]" | |
}, | |
"loadBalancerBackendAddressPools": [ | |
{ | |
"id": "[variables('lbPoolID')]" | |
} | |
], | |
"loadBalancerInboundNatPools": [ | |
{ | |
"id": "[resourceId('Microsoft.Network/loadBalancers/inboundNatPools', variables('loadBalancerName'), variables('natPoolName'))]" | |
} | |
] | |
} | |
} | |
] | |
} | |
} | |
] | |
}, | |
"extensionProfile": { | |
"extensions": [ | |
{ | |
"name": "Microsoft.Powershell.DSC", | |
"properties": { | |
"publisher": "Microsoft.Powershell", | |
"type": "DSC", | |
"typeHandlerVersion": "2.9", | |
"autoUpgradeMinorVersion": true, | |
"forceUpdateTag": "[parameters('powershelldscUpdateTagVersion')]", | |
"settings": { | |
"configuration": { | |
"url": "[variables('powershelldscZipFullPath')]", | |
"script": "InstallIIS.ps1", | |
"function": "InstallIIS" | |
}, | |
"configurationArguments": { | |
"nodeName": "localhost", | |
"WebDeployPackagePath": "[variables('webDeployPackageFullPath')]" | |
} | |
} | |
} | |
} | |
] | |
} | |
} | |
} | |
} | |
], | |
"outputs": { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment