2016-08-10 16:29:42 +03:00
|
|
|
{
|
|
|
|
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
|
|
|
"contentVersion": "1.0.0.0",
|
|
|
|
"parameters": {
|
|
|
|
"username": {
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
"metadata": {
|
2017-05-31 22:13:54 +03:00
|
|
|
"description": "Username for VPN and SSH"
|
2016-08-10 16:29:42 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"password": {
|
|
|
|
"type": "securestring",
|
|
|
|
"metadata": {
|
2017-05-31 22:13:54 +03:00
|
|
|
"description": "Password for VPN and SSH"
|
2016-08-10 16:29:42 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"preSharedKey": {
|
|
|
|
"type": "securestring",
|
|
|
|
"metadata": {
|
2017-05-31 22:13:54 +03:00
|
|
|
"description": "IPsec Pre-Shared Key for VPN"
|
2016-08-10 16:29:42 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"image": {
|
|
|
|
"type": "string",
|
|
|
|
"allowedValues": [
|
2017-05-31 22:13:54 +03:00
|
|
|
"ubuntu1604",
|
2018-05-10 10:57:08 +03:00
|
|
|
"debian9"
|
2016-08-10 16:29:42 +03:00
|
|
|
],
|
2018-05-10 10:57:08 +03:00
|
|
|
"defaultValue": "debian9",
|
2016-08-10 16:29:42 +03:00
|
|
|
"metadata": {
|
2018-05-10 10:57:08 +03:00
|
|
|
"description": "OS to use. Debian 9 or Ubuntu 16.04 LTS"
|
2016-08-10 16:29:42 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"VMSize": {
|
|
|
|
"type": "string",
|
2018-05-10 10:57:08 +03:00
|
|
|
"defaultValue": "Standard_B1s",
|
2016-08-10 16:29:42 +03:00
|
|
|
"allowedValues": [
|
2018-05-10 10:57:08 +03:00
|
|
|
"Standard_B1s",
|
|
|
|
"Standard_B1ms",
|
|
|
|
"Standard_B2s",
|
|
|
|
"Standard_B2ms"
|
2016-08-10 16:29:42 +03:00
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"description": "The size of the Virtual Machine."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"variables": {
|
|
|
|
"location": "[resourceGroup().location]",
|
|
|
|
"vmName": "vpnserver",
|
|
|
|
"virtualNetworkName": "vpnVnet",
|
|
|
|
"addressPrefix": "10.0.0.0/16",
|
|
|
|
"subnetName": "VPNSubnet",
|
|
|
|
"subnetPrefix": "10.0.1.0/24",
|
|
|
|
"apiVersion": "2015-06-15",
|
|
|
|
"storageName": "[concat(uniqueString(resourceGroup().id), 'vpnsa')]",
|
|
|
|
"vhdStorageType": "Standard_LRS",
|
|
|
|
"vnetId": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
|
|
|
|
"SubnetRef": "[concat(variables('vnetId'), '/subnets/', variables('subnetName'))]",
|
2017-05-31 22:13:54 +03:00
|
|
|
"ubuntu1604": {
|
2016-08-10 16:29:42 +03:00
|
|
|
"publisher": "Canonical",
|
|
|
|
"offer": "UbuntuServer",
|
2017-05-02 04:08:02 +03:00
|
|
|
"sku": "16.04-LTS",
|
2016-08-10 16:29:42 +03:00
|
|
|
"version": "latest"
|
|
|
|
},
|
2018-05-10 10:57:08 +03:00
|
|
|
"debian9": {
|
2016-08-10 16:29:42 +03:00
|
|
|
"publisher": "credativ",
|
|
|
|
"offer": "Debian",
|
2018-05-10 10:57:08 +03:00
|
|
|
"sku": "9",
|
2016-08-10 16:29:42 +03:00
|
|
|
"version": "latest"
|
|
|
|
},
|
2016-08-10 20:50:03 +03:00
|
|
|
"installScriptURL": "https://raw.githubusercontent.com/hwdsl2/setup-ipsec-vpn/master/azure/install.sh",
|
2016-08-10 16:29:42 +03:00
|
|
|
"installCommand": "[concat('sh install.sh ', parameters('preSharedKey'), ' ', parameters('username'), ' ', parameters('password'))]"
|
|
|
|
},
|
|
|
|
"resources": [
|
|
|
|
{
|
|
|
|
"type": "Microsoft.Storage/storageAccounts",
|
|
|
|
"name": "[variables('storageName')]",
|
2016-08-22 16:34:45 +03:00
|
|
|
"apiVersion": "2016-01-01",
|
2016-08-10 16:29:42 +03:00
|
|
|
"location": "[variables('location')]",
|
|
|
|
"tags": {
|
|
|
|
"displayName": "StorageAccount"
|
|
|
|
},
|
2016-08-22 16:34:45 +03:00
|
|
|
"properties": {},
|
|
|
|
"sku": {
|
|
|
|
"name": "[variables('vhdStorageType')]"
|
|
|
|
},
|
|
|
|
"kind": "Storage"
|
2016-08-10 16:29:42 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"apiVersion": "[variables('apiVersion')]",
|
|
|
|
"type": "Microsoft.Network/virtualNetworks",
|
|
|
|
"name": "[variables('virtualNetworkName')]",
|
|
|
|
"location": "[variables('location')]",
|
|
|
|
"tags": {
|
|
|
|
"displayName": "VirtualNetwork"
|
|
|
|
},
|
|
|
|
"properties": {
|
|
|
|
"addressSpace": {
|
|
|
|
"addressPrefixes": [
|
|
|
|
"[variables('addressPrefix')]"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"subnets": [
|
|
|
|
{
|
|
|
|
"name": "[variables('subnetName')]",
|
|
|
|
"properties": {
|
|
|
|
"addressPrefix": "[variables('subnetPrefix')]"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"apiVersion": "[variables('apiVersion')]",
|
|
|
|
"type": "Microsoft.Network/networkInterfaces",
|
|
|
|
"name": "[concat(variables('vmName'), 'nic')]",
|
|
|
|
"location": "[resourceGroup().location]",
|
|
|
|
"tags": {
|
|
|
|
"displayName": "NetworkInterface"
|
|
|
|
},
|
|
|
|
"dependsOn": [
|
|
|
|
"[concat('Microsoft.Network/virtualNetworks/', concat(variables('virtualNetworkName')))]",
|
|
|
|
"[concat('Microsoft.Network/publicIPAddresses/', concat(variables('vmName'), 'pip'))]",
|
|
|
|
"[concat('Microsoft.Network/networkSecurityGroups/', concat(variables('vmName'), 'nsg'))]"
|
|
|
|
],
|
|
|
|
"properties": {
|
|
|
|
"ipConfigurations": [
|
|
|
|
{
|
|
|
|
"name": "ipconfig1",
|
|
|
|
"properties": {
|
|
|
|
"privateIPAllocationMethod": "Dynamic",
|
|
|
|
"publicIPAddress": {
|
|
|
|
"id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('vmName'), 'pip'))]"
|
|
|
|
},
|
|
|
|
"subnet": {
|
|
|
|
"id": "[variables('subnetRef')]"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"networkSecurityGroup": {
|
|
|
|
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', concat(variables('vmName'), 'nsg'))]"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "Microsoft.Compute/virtualMachines",
|
|
|
|
"name": "[variables('vmName')]",
|
2016-08-22 16:34:45 +03:00
|
|
|
"apiVersion": "2016-03-30",
|
2016-08-10 16:29:42 +03:00
|
|
|
"location": "[resourceGroup().location]",
|
|
|
|
"tags": {
|
|
|
|
"displayName": "VirtualMachine"
|
|
|
|
},
|
|
|
|
"dependsOn": [
|
|
|
|
"[concat('Microsoft.Network/networkInterfaces/', concat(variables('vmName'), 'nic'))]"
|
|
|
|
],
|
|
|
|
"properties": {
|
|
|
|
"hardwareProfile": {
|
|
|
|
"vmSize": "[parameters('vmSize')]"
|
|
|
|
},
|
|
|
|
"osProfile": {
|
|
|
|
"computerName": "[variables('vmName')]",
|
|
|
|
"adminUsername": "[parameters('username')]",
|
|
|
|
"adminPassword": "[parameters('password')]"
|
|
|
|
},
|
|
|
|
"storageProfile": {
|
|
|
|
"imageReference": "[variables(parameters('image'))]",
|
|
|
|
"osDisk": {
|
|
|
|
"name": "osdisk",
|
|
|
|
"vhd": {
|
2016-08-22 16:34:45 +03:00
|
|
|
"uri": "[concat(reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageName'))).primaryEndpoints.blob, 'vmachines/', variables('vmName'), '.vhd')]"
|
2016-08-10 16:29:42 +03:00
|
|
|
},
|
|
|
|
"caching": "ReadWrite",
|
|
|
|
"createOption": "FromImage"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"networkProfile": {
|
|
|
|
"networkInterfaces": [
|
|
|
|
{
|
|
|
|
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('vmName'), 'nic'))]"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "Microsoft.Compute/virtualMachines/extensions",
|
|
|
|
"name": "[concat(variables('vmName'),'/installcustomscript')]",
|
|
|
|
"apiVersion": "[variables('apiVersion')]",
|
|
|
|
"location": "[resourceGroup().location]",
|
|
|
|
"tags": {
|
|
|
|
"displayName": "VirtualMachineCustomScriptExtension"
|
|
|
|
},
|
|
|
|
"dependsOn": [
|
|
|
|
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
|
|
|
|
],
|
|
|
|
"properties": {
|
2017-05-31 22:13:54 +03:00
|
|
|
"publisher": "Microsoft.Azure.Extensions",
|
|
|
|
"type": "CustomScript",
|
|
|
|
"typeHandlerVersion": "2.0",
|
|
|
|
"autoUpgradeMinorVersion": true,
|
2016-08-10 16:29:42 +03:00
|
|
|
"settings": {
|
|
|
|
"fileUris": [ "[variables('installScriptURL')]" ],
|
|
|
|
"commandToExecute": "[variables('installCommand')]"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "Microsoft.Network/networkSecurityGroups",
|
|
|
|
"name": "[concat(variables('vmName'), 'nsg')]",
|
|
|
|
"tags": {
|
|
|
|
"displayName": "NetworkSecurityGroup"
|
|
|
|
},
|
|
|
|
"apiVersion": "[variables('apiVersion')]",
|
|
|
|
"location": "[resourceGroup().location]",
|
|
|
|
"properties": {
|
|
|
|
"securityRules": [
|
|
|
|
{
|
|
|
|
"name": "default-ssh",
|
|
|
|
"properties": {
|
|
|
|
"protocol": "Tcp",
|
|
|
|
"sourcePortRange": "*",
|
|
|
|
"destinationPortRange": "22",
|
|
|
|
"sourceAddressPrefix": "*",
|
|
|
|
"destinationAddressPrefix": "*",
|
|
|
|
"access": "Allow",
|
|
|
|
"priority": 1000,
|
|
|
|
"direction": "Inbound"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "default-udp-500",
|
|
|
|
"properties": {
|
|
|
|
"protocol": "Udp",
|
|
|
|
"sourcePortRange": "*",
|
|
|
|
"destinationPortRange": "500",
|
|
|
|
"sourceAddressPrefix": "*",
|
|
|
|
"destinationAddressPrefix": "*",
|
|
|
|
"access": "Allow",
|
|
|
|
"priority": 2000,
|
|
|
|
"direction": "Inbound"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "default-udp-4500",
|
|
|
|
"properties": {
|
|
|
|
"protocol": "Udp",
|
|
|
|
"sourcePortRange": "*",
|
|
|
|
"destinationPortRange": "4500",
|
|
|
|
"sourceAddressPrefix": "*",
|
|
|
|
"destinationAddressPrefix": "*",
|
|
|
|
"access": "Allow",
|
|
|
|
"priority": 2001,
|
|
|
|
"direction": "Inbound"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"apiVersion": "[variables('apiVersion')]",
|
|
|
|
"type": "Microsoft.Network/publicIPAddresses",
|
|
|
|
"name": "[concat(variables('vmName'), 'pip')]",
|
|
|
|
"location": "[resourceGroup().location]",
|
|
|
|
"tags": {
|
|
|
|
"displayName": "PublicIPAddress"
|
|
|
|
},
|
|
|
|
"properties": {
|
|
|
|
"publicIPAllocationMethod": "Static"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"outputs": {
|
|
|
|
"Public IP": {
|
|
|
|
"type": "string",
|
|
|
|
"value": "[reference(concat(variables('vmName'), 'pip')).ipAddress]"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|