Created
February 1, 2016 19:50
-
-
Save tomasr/48b6eee760e1706bfb23 to your computer and use it in GitHub Desktop.
VM + P2S VPN ARM Template Example
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/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"adminUsername": { | |
"type": "string", | |
"minLength": 1, | |
"metadata": { | |
"description": "Username for the Virtual Machine." | |
} | |
}, | |
"adminPassword": { | |
"type": "securestring", | |
"metadata": { | |
"description": "Password for the Virtual Machine." | |
} | |
}, | |
"windowsOSVersion": { | |
"type": "string", | |
"defaultValue": "2012-R2-Datacenter", | |
"allowedValues": [ | |
"2008-R2-SP1", | |
"2012-Datacenter", | |
"2012-R2-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." | |
} | |
}, | |
"vpnGatewayName": { | |
"type": "string" | |
}, | |
"vpnGatewayDnsName": { | |
"type": "string" | |
}, | |
"vpnRootCert": { | |
"type": "string" | |
}, | |
"vpnClientAddressPool": { | |
"type": "string", | |
"metadata": { | |
"description": "IP Address and mask to use to assign client addresses in the form <ip>/<mask>" | |
}, | |
"defaultValue": "172.16.201.0/24" | |
} | |
}, | |
"variables": { | |
"imagePublisher": "MicrosoftWindowsServer", | |
"imageOffer": "WindowsServer", | |
"OSDiskName": "osdiskforwindowssimple", | |
"nicName": "myVMNic", | |
"addressPrefix": "10.0.0.0/16", | |
"subnetName": "Subnet", | |
"subnetPrefix": "10.0.1.0/24", | |
"vhdStorageType": "Standard_LRS", | |
"vhdStorageContainerName": "vhds", | |
"vmName": "MyWindowsVM", | |
"vmSize": "Standard_A2", | |
"virtualNetworkName": "MyVNET", | |
"vnetId": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]", | |
"subnetRef": "[concat(variables('vnetId'), '/subnets/', variables('subnetName'))]", | |
"vhdStorageName": "[concat('vhdstorage', uniqueString(resourceGroup().id))]", | |
"diagnosticsStorageAccountName": "[variables('vhdStorageName')]", | |
"diagnosticsStorageAccountResourceGroup": "[resourcegroup().name]", | |
"accountid": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', variables('diagnosticsStorageAccountResourceGroup'), '/providers/', 'Microsoft.Storage/storageAccounts/', variables('diagnosticsStorageAccountName'))]", | |
"wadlogs": "<WadCfg> <DiagnosticMonitorConfiguration overallQuotaInMB=\"4096\" xmlns=\"http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration\"> <DiagnosticInfrastructureLogs scheduledTransferLogLevelFilter=\"Error\"/> <WindowsEventLog scheduledTransferPeriod=\"PT1M\" > <DataSource name=\"Application!*[System[(Level = 1 or Level = 2)]]\" /> <DataSource name=\"Security!*[System[(Level = 1 or Level = 2)]]\" /> <DataSource name=\"System!*[System[(Level = 1 or Level = 2)]]\" /></WindowsEventLog>", | |
"wadperfcounters1": "<PerformanceCounters scheduledTransferPeriod=\"PT1M\"><PerformanceCounterConfiguration counterSpecifier=\"\\Processor(_Total)\\% Processor Time\" sampleRate=\"PT15S\" unit=\"Percent\"><annotation displayName=\"CPU utilization\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\Processor(_Total)\\% Privileged Time\" sampleRate=\"PT15S\" unit=\"Percent\"><annotation displayName=\"CPU privileged time\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\Processor(_Total)\\% User Time\" sampleRate=\"PT15S\" unit=\"Percent\"><annotation displayName=\"CPU user time\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\Processor Information(_Total)\\Processor Frequency\" sampleRate=\"PT15S\" unit=\"Count\"><annotation displayName=\"CPU frequency\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\System\\Processes\" sampleRate=\"PT15S\" unit=\"Count\"><annotation displayName=\"Processes\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\Process(_Total)\\Thread Count\" sampleRate=\"PT15S\" unit=\"Count\"><annotation displayName=\"Threads\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\Process(_Total)\\Handle Count\" sampleRate=\"PT15S\" unit=\"Count\"><annotation displayName=\"Handles\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\Memory\\% Committed Bytes In Use\" sampleRate=\"PT15S\" unit=\"Percent\"><annotation displayName=\"Memory usage\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\Memory\\Available Bytes\" sampleRate=\"PT15S\" unit=\"Bytes\"><annotation displayName=\"Memory available\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\Memory\\Committed Bytes\" sampleRate=\"PT15S\" unit=\"Bytes\"><annotation displayName=\"Memory committed\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\Memory\\Commit Limit\" sampleRate=\"PT15S\" unit=\"Bytes\"><annotation displayName=\"Memory commit limit\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\PhysicalDisk(_Total)\\% Disk Time\" sampleRate=\"PT15S\" unit=\"Percent\"><annotation displayName=\"Disk active time\" locale=\"en-us\"/></PerformanceCounterConfiguration>", | |
"wadperfcounters2": "<PerformanceCounterConfiguration counterSpecifier=\"\\PhysicalDisk(_Total)\\% Disk Read Time\" sampleRate=\"PT15S\" unit=\"Percent\"><annotation displayName=\"Disk active read time\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\PhysicalDisk(_Total)\\% Disk Write Time\" sampleRate=\"PT15S\" unit=\"Percent\"><annotation displayName=\"Disk active write time\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\PhysicalDisk(_Total)\\Disk Transfers/sec\" sampleRate=\"PT15S\" unit=\"CountPerSecond\"><annotation displayName=\"Disk operations\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\PhysicalDisk(_Total)\\Disk Reads/sec\" sampleRate=\"PT15S\" unit=\"CountPerSecond\"><annotation displayName=\"Disk read operations\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\PhysicalDisk(_Total)\\Disk Writes/sec\" sampleRate=\"PT15S\" unit=\"CountPerSecond\"><annotation displayName=\"Disk write operations\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\PhysicalDisk(_Total)\\Disk Bytes/sec\" sampleRate=\"PT15S\" unit=\"BytesPerSecond\"><annotation displayName=\"Disk speed\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\PhysicalDisk(_Total)\\Disk Read Bytes/sec\" sampleRate=\"PT15S\" unit=\"BytesPerSecond\"><annotation displayName=\"Disk read speed\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\PhysicalDisk(_Total)\\Disk Write Bytes/sec\" sampleRate=\"PT15S\" unit=\"BytesPerSecond\"><annotation displayName=\"Disk write speed\" locale=\"en-us\"/></PerformanceCounterConfiguration><PerformanceCounterConfiguration counterSpecifier=\"\\LogicalDisk(_Total)\\% Free Space\" sampleRate=\"PT15S\" unit=\"Percent\"><annotation displayName=\"Disk free space (percentage)\" locale=\"en-us\"/></PerformanceCounterConfiguration></PerformanceCounters>", | |
"wadcfgxstart": "[concat(variables('wadlogs'), variables('wadperfcounters1'), variables('wadperfcounters2'), '<Metrics resourceId=\"')]", | |
"wadmetricsresourceid": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', variables('diagnosticsStorageAccountResourceGroup'), '/providers/', 'Microsoft.Compute/virtualMachines/', variables('vmName'))]", | |
"wadcfgxend": "\"><MetricAggregation scheduledTransferPeriod=\"PT1H\"/><MetricAggregation scheduledTransferPeriod=\"PT1M\"/></Metrics></DiagnosticMonitorConfiguration></WadCfg>", | |
"vpnPublicIpName": "VPNPublicIP", | |
"vpnSubnet": "GatewaySubnet", | |
"vpnSubnetPrefix": "10.0.2.0/24", | |
"vpnSubnetRef": "[concat(variables('vnetId'), '/subnets/', variables('vpnSubnet'))]", | |
}, | |
"resources": [ | |
// VPN configuration | |
{ | |
"apiVersion": "2015-05-01-preview", | |
"type": "Microsoft.Network/virtualNetworks", | |
"name": "[variables('virtualNetworkName')]", | |
"location": "[resourceGroup().location]", | |
"tags": { | |
"displayName": "VirtualNetwork" | |
}, | |
"properties": { | |
"addressSpace": { | |
"addressPrefixes": [ | |
"[variables('addressPrefix')]" | |
] | |
}, | |
"subnets": [ | |
{ | |
"name": "[variables('subnetName')]", | |
"properties": { | |
"addressPrefix": "[variables('subnetPrefix')]" | |
} | |
}, | |
{ | |
"name": "[variables('vpnSubnet')]", | |
"properties": { | |
"addressPrefix": "[variables('vpnSubnetPrefix')]" | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"type": "Microsoft.Network/publicIPAddresses", | |
"name": "[variables('vpnPublicIpName')]", | |
"apiVersion": "2015-06-15", | |
"location": "[resourceGroup().location]", | |
"tags": { | |
"displayName": "VPN Public IP" | |
}, | |
"properties": { | |
"publicIPAllocationMethod": "Dynamic", | |
"dnsSettings": { | |
"domainNameLabel": "[parameters('vpnGatewayDnsName')]" | |
} | |
} | |
}, | |
{ | |
"type": "Microsoft.Network/virtualNetworkGateways", | |
"name": "[parameters('vpnGatewayName')]", | |
"apiVersion": "2015-06-15", | |
"location": "[resourceGroup().location]", | |
"dependsOn": [ | |
"[concat('Microsoft.Network/publicIPAddresses/', variables('vpnPublicIpName'))]", | |
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" | |
], | |
"tags": { | |
"displayName": "VPN Gateway" | |
}, | |
"properties": { | |
"ipConfigurations": [ | |
{ | |
"properties": { | |
"privateIPAllocationMethod": "Dynamic", | |
"subnet": { | |
"id": "[variables('vpnSubnetRef')]" | |
}, | |
"publicIPAddress": { | |
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('vpnPublicIpName'))]" | |
} | |
}, | |
"name": "vnetGatewayConfig" | |
} | |
], | |
"gatewayType": "Vpn", | |
"vpnType": "RouteBased", | |
"vpnClientConfiguration": { | |
"vpnClientAddressPool": { | |
"addressPrefixes": [ | |
"[parameters('vpnClientAddressPool')]" | |
] | |
}, | |
"vpnClientRootCertificates": [ | |
{ | |
"name": "vpnRootCertificate", | |
"properties": { | |
"publicCertData": "[parameters('vpnRootCert')]" | |
} | |
} | |
] | |
} | |
} | |
}, | |
// VM configuration | |
{ | |
"type": "Microsoft.Storage/storageAccounts", | |
"name": "[variables('vhdStorageName')]", | |
"apiVersion": "2015-06-15", | |
"location": "[resourceGroup().location]", | |
"tags": { | |
"displayName": "StorageAccount" | |
}, | |
"properties": { | |
"accountType": "[variables('vhdStorageType')]" | |
} | |
}, | |
{ | |
"apiVersion": "2015-05-01-preview", | |
"type": "Microsoft.Network/networkInterfaces", | |
"name": "[variables('nicName')]", | |
"location": "[resourceGroup().location]", | |
"tags": { | |
"displayName": "NetworkInterface" | |
}, | |
"dependsOn": [ | |
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" | |
], | |
"properties": { | |
"ipConfigurations": [ | |
{ | |
"name": "ipconfig1", | |
"properties": { | |
"privateIPAllocationMethod": "Dynamic", | |
"subnet": { | |
"id": "[variables('subnetRef')]" | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"apiVersion": "2015-06-15", | |
"type": "Microsoft.Compute/virtualMachines", | |
"name": "[variables('vmName')]", | |
"location": "[resourceGroup().location]", | |
"tags": { | |
"displayName": "VirtualMachine" | |
}, | |
"dependsOn": [ | |
"[concat('Microsoft.Storage/storageAccounts/', variables('vhdStorageName'))]", | |
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" | |
], | |
"properties": { | |
"hardwareProfile": { | |
"vmSize": "[variables('vmSize')]" | |
}, | |
"osProfile": { | |
"computerName": "[variables('vmName')]", | |
"adminUsername": "[parameters('adminUsername')]", | |
"adminPassword": "[parameters('adminPassword')]" | |
}, | |
"storageProfile": { | |
"imageReference": { | |
"publisher": "[variables('imagePublisher')]", | |
"offer": "[variables('imageOffer')]", | |
"sku": "[parameters('windowsOSVersion')]", | |
"version": "latest" | |
}, | |
"osDisk": { | |
"name": "osdisk", | |
"vhd": { | |
"uri": "[concat('http://', variables('vhdStorageName'), '.blob.core.windows.net/', variables('vhdStorageContainerName'), '/', variables('OSDiskName'), '.vhd')]" | |
}, | |
"caching": "ReadWrite", | |
"createOption": "FromImage" | |
} | |
}, | |
"networkProfile": { | |
"networkInterfaces": [ | |
{ | |
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" | |
} | |
] | |
}, | |
"diagnosticsProfile": { | |
"bootDiagnostics": { | |
"enabled": true, | |
"storageUri": "[concat('http://', variables('diagnosticsStorageAccountName'), '.blob.core.windows.net')]" | |
} | |
} | |
}, | |
"resources": [ | |
{ | |
"type": "extensions", | |
"name": "Microsoft.Insights.VMDiagnosticsSettings", | |
"apiVersion": "2015-06-15", | |
"location": "[resourceGroup().location]", | |
"tags": { | |
"displayName": "AzureDiagnostics" | |
}, | |
"dependsOn": [ | |
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]" | |
], | |
"properties": { | |
"publisher": "Microsoft.Azure.Diagnostics", | |
"type": "IaaSDiagnostics", | |
"typeHandlerVersion": "1.5", | |
"autoUpgradeMinorVersion": true, | |
"settings": { | |
"xmlCfg": "[base64(concat(variables('wadcfgxstart'), variables('wadmetricsresourceid'), variables('wadcfgxend')))]", | |
"storageAccount": "[variables('diagnosticsStorageAccountName')]" | |
}, | |
"protectedSettings": { | |
"storageAccountName": "[variables('diagnosticsStorageAccountName')]", | |
"storageAccountKey": "[listkeys(variables('accountid'), '2015-06-15').key1]", | |
"storageAccountEndPoint": "https://core.windows.net" | |
} | |
} | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice