234 lines
7.4 KiB
JSON
234 lines
7.4 KiB
JSON
|
{
|
||
|
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||
|
"contentVersion": "1.0.0.0",
|
||
|
"parameters": {
|
||
|
"adminUsername": {
|
||
|
"type": "string",
|
||
|
"metadata": {
|
||
|
"description": "Username for the Virtual Machine."
|
||
|
}
|
||
|
},
|
||
|
"adminPassword": {
|
||
|
"type": "securestring",
|
||
|
"metadata": {
|
||
|
"description": "Password for the Virtual Machine."
|
||
|
}
|
||
|
},
|
||
|
"dnsNameForPublicIP": {
|
||
|
"type": "string",
|
||
|
"metadata": {
|
||
|
"description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
"variables": {
|
||
|
"storageAccountName": "[concat(uniquestring(resourceGroup().id),'storage')]",
|
||
|
"imagePublisher": "Canonical",
|
||
|
"imageOffer": "UbuntuServer",
|
||
|
"OSDiskName": "openvpn-vhd",
|
||
|
"imageSKU": "16.04.0-LTS",
|
||
|
"nicName": "openvpnNic",
|
||
|
"addressPrefix": "10.0.0.0/16",
|
||
|
"subnetName": "openvpnSubnet",
|
||
|
"subnetPrefix": "10.0.0.0/24",
|
||
|
"storageAccountType": "Standard_LRS",
|
||
|
"publicIPAddressName": "openvpnPublicIP",
|
||
|
"publicIPAddressType": "Dynamic",
|
||
|
"vmStorageAccountContainerName": "vhds",
|
||
|
"vmName": "openvpnVM",
|
||
|
"vmSize": "Basic_A0",
|
||
|
"virtualNetworkName": "openvpnVNET",
|
||
|
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
|
||
|
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
|
||
|
"apiVersion": "2015-06-15"
|
||
|
},
|
||
|
"resources": [
|
||
|
{
|
||
|
"type": "Microsoft.Storage/storageAccounts",
|
||
|
"name": "[variables('storageAccountName')]",
|
||
|
"apiVersion": "[variables('apiVersion')]",
|
||
|
"location": "[resourceGroup().location]",
|
||
|
"properties": {
|
||
|
"accountType": "[variables('storageAccountType')]"
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"apiVersion": "[variables('apiVersion')]",
|
||
|
"type": "Microsoft.Network/publicIPAddresses",
|
||
|
"name": "[variables('publicIPAddressName')]",
|
||
|
"location": "[resourceGroup().location]",
|
||
|
"properties": {
|
||
|
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
|
||
|
"dnsSettings": {
|
||
|
"domainNameLabel": "[parameters('dnsNameForPublicIP')]"
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"apiVersion": "[variables('apiVersion')]",
|
||
|
"type": "Microsoft.Network/virtualNetworks",
|
||
|
"name": "[variables('virtualNetworkName')]",
|
||
|
"location": "[resourceGroup().location]",
|
||
|
"properties": {
|
||
|
"addressSpace": {
|
||
|
"addressPrefixes": [
|
||
|
"[variables('addressPrefix')]"
|
||
|
]
|
||
|
},
|
||
|
"subnets": [
|
||
|
{
|
||
|
"name": "[variables('subnetName')]",
|
||
|
"properties": {
|
||
|
"addressPrefix": "[variables('subnetPrefix')]"
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"apiVersion": "[variables('apiVersion')]",
|
||
|
"type": "Microsoft.Network/networkInterfaces",
|
||
|
"name": "[variables('nicName')]",
|
||
|
"location": "[resourceGroup().location]",
|
||
|
"dependsOn": [
|
||
|
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
|
||
|
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]",
|
||
|
"[concat('Microsoft.Network/networkSecurityGroups/', 'openvpn-nsg')]"
|
||
|
],
|
||
|
"properties": {
|
||
|
"ipConfigurations": [
|
||
|
{
|
||
|
"name": "ipconfig1",
|
||
|
"properties": {
|
||
|
"privateIPAllocationMethod": "Dynamic",
|
||
|
"publicIPAddress": {
|
||
|
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
|
||
|
},
|
||
|
"subnet": {
|
||
|
"id": "[variables('subnetRef')]"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"name": "['openvpn-nsg']",
|
||
|
"type": "Microsoft.Network/networkSecurityGroups",
|
||
|
"apiVersion": "2016-09-01",
|
||
|
"location": "[resourceGroup().location]",
|
||
|
"properties": {
|
||
|
"securityRules": [
|
||
|
{
|
||
|
"name": "default-allow-ssh",
|
||
|
"properties": {
|
||
|
"priority": 1000,
|
||
|
"sourceAddressPrefix": "*",
|
||
|
"protocol": "TCP",
|
||
|
"destinationPortRange": "22",
|
||
|
"access": "Allow",
|
||
|
"direction": "Inbound",
|
||
|
"sourcePortRange": "*",
|
||
|
"destinationAddressPrefix": "*"
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"name": "default-allow-openvpn",
|
||
|
"properties": {
|
||
|
"priority": 1100,
|
||
|
"sourceAddressPrefix": "*",
|
||
|
"protocol": "UDP",
|
||
|
"destinationPortRange": "1194",
|
||
|
"access": "Allow",
|
||
|
"direction": "Inbound",
|
||
|
"sourcePortRange": "*",
|
||
|
"destinationAddressPrefix": "*"
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"name": "default-allow-https",
|
||
|
"properties": {
|
||
|
"priority": 1200,
|
||
|
"sourceAddressPrefix": "*",
|
||
|
"protocol": "UDP",
|
||
|
"destinationPortRange": "443",
|
||
|
"access": "Allow",
|
||
|
"direction": "Inbound",
|
||
|
"sourcePortRange": "*",
|
||
|
"destinationAddressPrefix": "*"
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||
|
"name": "[concat(variables('vmName'),'/', 'openvpn-setup')]",
|
||
|
"apiVersion": "['2015-06-15']",
|
||
|
"location": "[resourceGroup().location]",
|
||
|
"dependsOn": [
|
||
|
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
|
||
|
],
|
||
|
"properties": {
|
||
|
"publisher": "Microsoft.Azure.Extensions",
|
||
|
"type": "CustomScript",
|
||
|
"typeHandlerVersion": "2.0",
|
||
|
"autoUpgradeMinorVersion": true,
|
||
|
"settings": {
|
||
|
"fileUris": "[split('https://raw.githubusercontent.com/theonemule/simple-openvpn-server/master/openvpn.sh', ' ')]",
|
||
|
"commandToExecute": "[concat('bash openvpn.sh --host=', parameters('dnsNameForPublicIP'), '.', resourceGroup().location, '.cloudapp.azure.com --adminpassword=', parameters('adminPassword'))]"
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"apiVersion": "2016-04-30-preview",
|
||
|
"type": "Microsoft.Compute/virtualMachines",
|
||
|
"name": "[variables('vmName')]",
|
||
|
"location": "[resourceGroup().location]",
|
||
|
"dependsOn": [
|
||
|
"[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
|
||
|
"[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": "[variables('imageSKU')]",
|
||
|
"version": "latest"
|
||
|
},
|
||
|
"osDisk": {
|
||
|
"createOption": "FromImage"
|
||
|
}
|
||
|
},
|
||
|
"networkProfile": {
|
||
|
"networkInterfaces": [
|
||
|
{
|
||
|
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
|
||
|
}
|
||
|
]
|
||
|
},
|
||
|
"diagnosticsProfile": {
|
||
|
"bootDiagnostics": {
|
||
|
"enabled": "true",
|
||
|
"storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName')), variables('apiVersion')).primaryEndpoints.blob)]"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
],
|
||
|
"outputs": {
|
||
|
"httpSite": {
|
||
|
"type": "string",
|
||
|
"value": "[concat('Browse to: ', parameters('dnsNameForPublicIP'), '.', resourceGroup().location, '.cloudapp.azure.com and logon with u:admin p:', parameters('adminPassword'))]"
|
||
|
}
|
||
|
}
|
||
|
}
|