Skip to content

Instantly share code, notes, and snippets.

@esell
Created March 1, 2018 22:51
Show Gist options
  • Save esell/017e7fba550337a0c571efc415ead428 to your computer and use it in GitHub Desktop.
Save esell/017e7fba550337a0c571efc415ead428 to your computer and use it in GitHub Desktop.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"automationAccountName": {
"type": "string",
"metadata": {
"description": "Specify the name of your Automation Account"
}
},
"automationRegion": {
"type": "string",
"allowedValues": [
"westeurope",
"southeastasia",
"eastus2",
"southcentralus",
"japaneast",
"northeurope",
"canadacentral",
"australiasoutheast",
"centralindia",
"westcentralus"
],
"metadata": {
"description": "Specify the region for your automation account"
}
},
"_artifactsLocation": {
"type": "string",
"defaultValue": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/asr-automation-recovery",
"metadata": {
"description": "URI to artifacts location"
}
},
"_artifactsLocationSasToken": {
"type": "securestring",
"defaultValue": "",
"metadata": {
"description": "The sasToken required to access _artifactsLocation. When the template is deployed using the accompanying scripts, a sasToken will be automatically generated"
}
},
"dnsNameforLBIP": {
"defaultValue": "mylbasrdnsesell",
"type": "String",
"metadata": {
"description": "DNS for Load Balancer IP"
}
},
"lbName": {
"defaultValue": "myLB-asresell",
"type": "String",
"metadata": {
"description": "Load Balancer name"
}
},
"lbtype": {
"defaultValue": "Basic",
"type": "String",
"metadata": {
"description": "Load Balancer type"
}
},
"publicIPAddressName": {
"defaultValue": "myPublicIPasr",
"type": "String",
"metadata": {
"description": "Public IP Name"
}
},
"networkSecurityGroupName": {
"defaultValue": "new-nsg-asr",
"type": "string",
"metadata": {
"description": "Network security group name"
}
},
"vaults_asr_vault_name": {
"defaultValue": "asr-vault",
"type": "String"
},
"virtualNetworks_myVNET_asr_name": {
"defaultValue": "myVNET-asr",
"type": "String"
},
"availabilitySets_MYAVSET_asr_name": {
"defaultValue": "MYAVSET-asr",
"type": "String"
},
"subnets_Subnet_1_name": {
"defaultValue": "Subnet-1",
"type": "String"
}
},
"variables": {
"addressprefixforsubnet" : "10.0.0.0/24",
"addressprefixforvnet" : "10.0.0.0/16",
"publicIPAddressType": "Dynamic",
"nsgid" : "[resourceId('Microsoft.Network/networkSecurityGroups',parameters('networkSecurityGroupName'))]",
"publicIPAddressID": "[resourceId('Microsoft.Network/publicIPAddresses',parameters('publicIPAddressName'))]",
"lbID": "[resourceId('Microsoft.Network/loadBalancers',parameters('lbName'))]",
"frontEndIPConfigID": "[concat(variables('lbID'),'/frontendIPConfigurations/LoadBalancerFrontEnd')]",
"lbPoolID": "[concat(variables('lbID'),'/backendAddressPools/BackendPool1')]",
"lbProbeID": "[concat(variables('lbID'),'/probes/tcpProbe')]",
"asrScripts": {
"runbooks": [
{
"name": "ASR-AddPublicIp",
"url": "[concat(parameters('_artifactsLocation'), '/scripts/ASR-AddPublicIp.ps1', parameters('_artifactsLocationSasToken'))]",
"version": "1.0.0.0",
"type": "PowerShell",
"description": "ASR Runbook to enable public IP on every VM in a Recovery Plan"
},
{
"name": "ASR-SQL-FailoverAG",
"url": "[concat(parameters('_artifactsLocation'), '/scripts/ASR-SQL-FailoverAG.ps1', parameters('_artifactsLocationSasToken'))]",
"version": "1.0.0.0",
"type": "PowerShellWorkflow",
"description": "ASR Runbook to handle SQL Always On failover"
},
{
"name": "ASR-AddSingleNSGPublicIp",
"url": "[concat(parameters('_artifactsLocation'), '/scripts/ASR-AddSingleNSGPublicIp.ps1', parameters('_artifactsLocationSasToken'))]",
"version": "1.0.0.0",
"type": "PowerShell",
"description": "ASR Runbook to enable NSG and Public IP on every VM in a Recovery Plan"
},
{
"name": "ASR-AddSingleLoadBalancer",
"url": "[concat(parameters('_artifactsLocation'), '/scripts/ASR-AddSingleLoadBalancer.ps1', parameters('_artifactsLocationSasToken'))]",
"version": "1.0.0.0",
"type": "PowerShell",
"description": "ASR Runbook to enable a single Load Balancer for all the VMs in the recovery plan"
},
{
"name": "ASR-AddMulitpleLoadBalancers",
"url": "[concat(parameters('_artifactsLocation'), '/scripts/ASR-AddMultipleLoadBalancers.ps1', parameters('_artifactsLocationSasToken'))]",
"version": "1.0.0.0",
"type": "PowerShell",
"description": "ASR Runbook to enable multiple Load Balancers for selected VMs in the recovery plan"
},
{
"name": "ASR-DNS-UpdateIP",
"url": "[concat(parameters('_artifactsLocation'), '/scripts/ASR-DNS-UpdateIP.ps1', parameters('_artifactsLocationSasToken'))]",
"version": "1.0.0.0",
"type": "PowerShellWorkflow",
"description": "ASR Runbook to update DNS for VMs within the recovery plan"
},
{
"name": "ASR-Wordpress-ChangeMysqlConfig",
"url": "[concat(parameters('_artifactsLocation'), '/scripts/ASR-Wordpress-ChangeMysqlConfig.ps1', parameters('_artifactsLocationSasToken'))]",
"version": "1.0.0.0",
"type": "PowerShellWorkflow",
"description": "ASR Runbook to configure Mysql as part of a recovery plan"
},
{
"name": "ASR-SQL-FailoverAGClassic",
"url": "[concat(parameters('_artifactsLocation'), '/scripts/ASR-SQL-FailoverAGClassic.ps1', parameters('_artifactsLocationSasToken'))]",
"version": "1.0.0.0",
"type": "PowerShellWorkflow",
"description": "ASR Runbook to failover SQL Availability Groups"
}
],
"modules": [
{
"name": "AzureRm.Compute",
"url": "https://devopsgallerystorage.blob.core.windows.net/packages/azurerm.compute.4.2.0.nupkg"
},
{
"name": "AzureRm.Resources",
"url": "https://devopsgallerystorage.blob.core.windows.net/packages/azurerm.resources.5.2.0.nupkg"
},
{
"name": "AzureRm.Network",
"url": "https://devopsgallerystorage.blob.core.windows.net/packages/azurerm.network.5.1.0.nupkg"
},{
"name": "AzureRm.TrafficManager",
"url": "https://devopsgallerystorage.blob.core.windows.net/packages/azurerm.trafficmanager.4.0.1.nupkg"
},
{
"name": "AzureRm.Automation",
"url": "https://devopsgallerystorage.blob.core.windows.net/packages/azurerm.automation.4.2.0.nupkg"
}
]
},
"azureRmProfile": {
"name": "AzureRm.Profile",
"url": "https://devopsgallerystorage.blob.core.windows.net/packages/azurerm.profile.4.2.0.nupkg"
}
},
"resources": [
{
"apiVersion": "2015-10-31",
"type": "Microsoft.Automation/automationAccounts/runbooks",
"name": "[concat(parameters('automationAccountName'), '/', variables('asrScripts').runbooks[copyIndex()].Name)]",
"location": "[parameters('automationRegion')]",
"dependsOn": [
],
"copy": {
"name": "runbooksLoop",
"count": "[length(variables('asrScripts').runbooks)]"
},
"properties": {
"description": "[variables('asrScripts').runbooks[copyIndex()].description]",
"runbookType": "[variables('asrScripts').runbooks[copyIndex()].type]",
"logProgress": false,
"logVerbose": true,
"publishContentLink": {
"uri": "[variables('asrScripts').runbooks[copyIndex()].url]",
"version": "[variables('asrScripts').runbooks[copyIndex()].version]"
}
}
},
{
"apiVersion": "2015-10-31",
"type": "Microsoft.Automation/automationAccounts/modules",
"name": "[concat(parameters('automationAccountName'), '/', variables('azureRmProfile').name)]",
"location": "[parameters('automationRegion')]",
"dependsOn": [
],
"properties": {
"contentLink": {
"uri": "[variables('azureRmProfile').url]"
}
}
},
{
"apiVersion": "2015-10-31",
"type": "Microsoft.Automation/automationAccounts/modules",
"name": "[concat(parameters('automationAccountName'), '/', variables('asrScripts').modules[copyIndex()].Name)]",
"location": "[parameters('automationRegion')]",
"dependsOn": [
"[resourceId('Microsoft.Automation/automationAccounts/modules/', parameters('automationAccountName'), variables('azureRmProfile').name)]"
],
"copy": {
"name": "modulesLoop",
"count": "[length(variables('asrScripts').modules)]"
},
"properties": {
"contentLink": {
"uri": "[variables('asrScripts').modules[copyIndex()].url]"
}
}
},
{
"type": "Microsoft.Compute/availabilitySets",
"sku": {
"name": "Aligned"
},
"name": "[parameters('availabilitySets_MYAVSET_asr_name')]",
"apiVersion": "2017-03-30",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"platformUpdateDomainCount": 2,
"platformFaultDomainCount": 2,
"virtualMachines": []
},
"dependsOn": []
},
{
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('virtualNetworks_myVNET_asr_name')]",
"apiVersion": "2017-10-01",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressprefixforvnet')]"
]
},
"dhcpOptions": {
"dnsServers": []
},
"subnets": [
{
"name": "Subnet-1",
"properties": {
"addressPrefix": "[variables('addressprefixforsubnet')]"
}
}
],
"virtualNetworkPeerings": [],
"enableDdosProtection": false,
"enableVmProtection": false
},
"dependsOn": []
},
{
"type": "Microsoft.RecoveryServices/vaults",
"sku": {
"name": "RS0",
"tier": "Standard"
},
"name": "[parameters('vaults_asr_vault_name')]",
"apiVersion": "2017-07-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {},
"dependsOn": []
},
{
"type": "Microsoft.Network/publicIPAddresses",
"name": "[parameters('publicIPAddressName')]",
"apiVersion": "2017-11-01",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
"dnsSettings": {
"domainNameLabel": "[parameters('dnsNameforLBIP')]"
}
}
},
{
"type": "Microsoft.Network/loadBalancers",
"name": "[parameters('lbName')]",
"sku": {
"name": "[parameters('lbtype')]"
},
"apiVersion": "2017-11-01",
"location": "[resourceGroup().location]",
"properties": {
"frontendIPConfigurations": [
{
"name": "LoadBalancerFrontEnd",
"properties": {
"publicIPAddress": {
"id": "[variables('publicIPAddressID')]"
}
}
}
],
"backendAddressPools": [
{
"name": "BackendPool1"
}
],
"inboundNatRules": [
{
"name": "SSH-VM1",
"properties": {
"frontendIPConfiguration": {
"id": "[variables('frontEndIPConfigID')]"
},
"protocol": "tcp",
"frontendPort": 60001,
"backendPort": 22,
"enableFloatingIP": false
}
},
{
"name": "SSH-VM0",
"properties": {
"frontendIPConfiguration": {
"id": "[variables('frontEndIPConfigID')]"
},
"protocol": "tcp",
"frontendPort": 60002,
"backendPort": 22,
"enableFloatingIP": false
}
}
],
"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
}
}
]
},
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', parameters('publicIPAddressName'))]"
]
},
{
"name": "[parameters('networkSecurityGroupName')]",
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2016-09-01",
"location": "[resourceGroup().location]",
"properties": {
"securityRules": [
{
"name": "HTTP",
"properties": {
"protocol": "TCP",
"sourcePortRange": "*",
"destinationPortRange": "80",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 1003,
"direction": "Inbound"
}
},
{
"name": "Mysql",
"properties": {
"protocol": "TCP",
"sourcePortRange": "*",
"destinationPortRange": "3306",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 1002,
"direction": "Inbound"
}
},
{
"name": "ssh",
"properties": {
"protocol": "TCP",
"sourcePortRange": "*",
"destinationPortRange": "22",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 1001,
"direction": "Inbound"
}
},
{
"name": "default-allow-rdp",
"properties": {
"priority": 1000,
"sourceAddressPrefix": "*",
"protocol": "TCP",
"destinationPortRange": "3389",
"access": "Allow",
"direction": "Inbound",
"sourcePortRange": "*",
"destinationAddressPrefix": "*"
}
}
]
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment