MTC_APPContainerization/Java Containerization/azuredeploy.json

758 строки
26 KiB
JSON

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"javaPackageName": {
"type": "string",
"defaultValue": "openjdk-11-jdk",
"allowedValues": [
"openjdk-11-jdk",
"openjdk-12-jdk",
"openjdk-13-jdk"
],
"metadata": {
"description": "java Package Name"
}
},
"tomcatPackageName": {
"type": "string",
"metadata": {
"description": "tomcat Package Name"
}
},
"airsonicPackageName": {
"type": "string",
"metadata": {
"description": "location of airsonic app package"
}
},
"tomcatContext": {
"type": "string",
"metadata": {
"description": "tomcat context for airsonic app"
}
},
"tomcatServiceFile": {
"type": "string",
"metadata": {
"description": "tomcat service file for systemd"
}
},
"tomcatUsersFile": {
"type": "string",
"metadata": {
"description": "tomcat user admin file"
}
},
"tomcatServerConf": {
"type": "string",
"metadata": {
"description": "tomcat server conf"
}
},
"tomcatManagerContext": {
"type": "string",
"metadata": {
"description": "tomcat management file"
}
},
"tomcatHostManagerContext": {
"type": "string",
"metadata": {
"description": "tomcat host management file"
}
},
"mysqlDriverName": {
"type": "string",
"metadata": {
"description": "mysql java driver"
}
},
"vmAdminUsername": {
"type": "string",
"metadata": {
"description": "User name for the Virtual Machine."
}
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_D2s_v3",
"metadata": {
"description": "The size of the virtual machines used when provisioning"
}
},
"ubuntuOSVersion": {
"type": "string",
"defaultValue": "18.04-LTS",
"allowedValues": [
"18.04-LTS",
"16.04-LTS",
"14.04.5-LTS"
],
"metadata": {
"description": "The Ubuntu version for the VM. This will pick a fully patched image of this given Ubuntu version."
}
},
"resourceLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
},
"authenticationType": {
"type": "securestring",
"defaultValue": "password",
"allowedValues": [
"sshPublicKey",
"password"
],
"metadata": {
"description": "Type of authentication to use on the Virtual Machine. SSH key is recommended."
}
},
"vmAdminPasswordOrKey": {
"type": "securestring",
"metadata": {
"description": "SSH Key or password for the Virtual Machine. SSH key is recommended."
}
},
"mysqlServername": {
"type": "string",
"defaultValue": "[concat('airsonic-mysql-server-', utcNow('MMddyyHmmss'))]",
"metadata": {
"description": "MySQL Server name for the demo db"
}
},
"mysqlDBName": {
"type": "string",
"metadata": {
"description": "MySQL Server name for the demo db"
}
},
"mysqlAdminName": {
"type": "securestring",
"metadata": {
"description": "MySQL server admin name for the demo db"
}
},
"mysqlAdminPass": {
"type": "securestring",
"metadata": {
"description": "MySQL server pass for the demo db"
}
},
"mysqlClientPackage": {
"type": "string",
"metadata": {
"description": "MySQL client package"
}
},
"bastionHosts_bastion_name": {
"defaultValue": "bastion-host",
"type": "String"
},
"_artifactsLocation": {
"type": "string",
"metadata": {
"description": "The base URI where artifacts required by this template are located."
}
},
"_artifactsLocationSasToken": {
"type": "securestring",
"metadata": {
"description": "The sasToken required to access _artifactsLocation. When the template is deployed using the accompanying scripts, a sasToken will be automatically generated."
},
"defaultValue": ""
},
"vmTCCustomScriptFileName": {
"type": "string",
"metadata": {
"description": "Tool server setup script name"
}
},
"vmTCCustomScriptUri": {
"type": "string",
"metadata": {
"description": "Tool server setup script base path"
}
}
},
"variables": {
"imagePublisher": "Canonical",
"imageOffer": "UbuntuServer",
"lnicName": "tomcatVMNic",
"nsgName": "labNSG",
"lvmName": "TomcatServer",
"appContainerizationToolServer": "tomcatMigrate-toolclient",
"tnicName": "toolVMNic",
"addressPrefix": "10.0.0.0/16",
"subnetName": "labSubnet",
"subnetPrefix": "10.0.0.0/24",
"publicIPAddressName": "tomcatPublicIP",
"tpublicIPAddressName": "toolPublicIP",
"bpublicIPAddressName": "bastionPublicIP",
"virtualNetworkName": "labVNET",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "[concat('/home/', parameters('vmAdminUsername'), '/.ssh/authorized_keys')]",
"keyData": "[parameters('vmAdminPasswordOrKey')]"
}
]
}
},
"networkSecurityGroupName": "default-NSG",
"tnetworkSecurityGroupName": "default-Tool-NSG"
},
"resources": [
{
"apiVersion": "2019-06-01",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIPAddressName')]",
"location": "[parameters('resourceLocation')]",
"sku": {
"name": "Basic"
},
"properties": {
"publicIPAllocationMethod": "Dynamic"
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2020-11-01",
"name": "[variables('tpublicIPAddressName')]",
"location": "[parameters('resourceLocation')]",
"sku": {
"name": "Basic",
"tier": "Regional"
},
"properties": {
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Dynamic",
"idleTimeoutInMinutes": 4,
"ipTags": []
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2020-11-01",
"name": "[variables('bpublicIPAddressName')]",
"location": "[parameters('resourceLocation')]",
"sku": {
"name": "Standard",
"tier": "Regional"
},
"properties": {
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Static",
"idleTimeoutInMinutes": 4,
"ipTags": []
}
},
{
"comments": "Default Network Security Group for template",
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2019-08-01",
"name": "[variables('networkSecurityGroupName')]",
"location": "[parameters('resourceLocation')]",
"properties": {
"securityRules": [
{
"name": "default-allow-22",
"properties": {
"priority": 1000,
"access": "Allow",
"direction": "Inbound",
"destinationPortRange": "22",
"protocol": "Tcp",
"sourceAddressPrefix": "*",
"sourcePortRange": "*",
"destinationAddressPrefix": "*"
}
},
{
"name": "default-allow-8080",
"properties": {
"priority": 1010,
"access": "Allow",
"direction": "Inbound",
"destinationPortRange": "8080",
"protocol": "Tcp",
"sourceAddressPrefix": "*",
"sourcePortRange": "*",
"destinationAddressPrefix": "*"
}
},
{
"name": "default-allow-ping",
"properties": {
"priority": 1020,
"access": "Allow",
"direction": "Inbound",
"destinationPortRange": "*",
"protocol": "ICMP",
"sourceAddressPrefix": "*",
"sourcePortRange": "*",
"destinationAddressPrefix": "*"
}
}
]
}
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2020-11-01",
"name": "[variables('tnetworkSecurityGroupName')]",
"location": "[parameters('resourceLocation')]",
"properties": {
"securityRules": []
}
},
{
"apiVersion": "2019-06-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"location": "[parameters('resourceLocation')]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
],
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
}
}
},
{
"name": "AzureBastionSubnet",
"properties": {
"addressPrefix": "10.0.1.0/24",
"serviceEndpoints": [],
"delegations": [],
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
}
]
}
},
{
"apiVersion": "2019-06-01",
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('lnicName')]",
"location": "[parameters('resourceLocation')]",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
},
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]"
}
}
}
],
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
}
}
},
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2020-11-01",
"name": "[variables('tnicName')]",
"location": "[parameters('resourceLocation')]",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('tpublicIPAddressName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('tnetworkSecurityGroupName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAddress": "10.0.0.4",
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('tpublicIPAddressName'))]"
},
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]"
},
"primary": true,
"privateIPAddressVersion": "IPv4"
}
}
],
"dnsSettings": {
"dnsServers": []
},
"enableAcceleratedNetworking": false,
"enableIPForwarding": false,
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('tnetworkSecurityGroupName'))]"
}
}
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2019-06-01",
"name": "[variables('nsgName')]",
"location": "[parameters('resourceLocation')]",
"properties": {
"securityRules": [
{
"name": "SSH",
"properties": {
"description": "Allow SSH",
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "22",
"sourceAddressPrefix": "Internet",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 100,
"direction": "Inbound"
}
},
{
"name": "Web",
"properties": {
"description": "Allow Web",
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "8080",
"sourceAddressPrefix": "Internet",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 112,
"direction": "Inbound"
}
},
{
"name": "Ping",
"properties": {
"description": "Allow ping",
"protocol": "ICMP",
"sourcePortRange": "*",
"destinationPortRange": "*",
"sourceAddressPrefix": "Internet",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 101,
"direction": "Inbound"
}
}
]
}
},
{
"apiVersion": "2019-07-01",
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('lvmName')]",
"location": "[parameters('resourceLocation')]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces', variables('lnicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[variables('lvmName')]",
"adminUsername": "[parameters('vmAdminUsername')]",
"adminPassword": "[parameters('vmAdminPasswordOrKey')]",
"linuxConfiguration": "[if(equals(parameters('authenticationType'), 'password'), json('null'), variables('linuxConfiguration'))]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[parameters('ubuntuOSVersion')]",
"version": "latest"
},
"osDisk": {
"osType": "Linux",
"name": "[concat(variables('lvmName'),'_OSDisk')]",
"caching": "ReadWrite",
"createOption": "FromImage",
"managedDisk": {
"storageAccountType": "StandardSSD_LRS"
}
},
"dataDisks": [
{
"lun": 0,
"name": "[concat(variables('lvmName'),'_DataDisk_0')]",
"createOption": "Empty",
"caching": "None",
"writeAcceleratorEnabled": false,
"managedDisk": {
"storageAccountType": "Premium_LRS"
},
"diskSizeGB": 32,
"toBeDetached": false
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('lnicName'))]"
}
]
}
}
},
{
"type": "Microsoft.Network/bastionHosts",
"apiVersion": "2020-11-01",
"name": "[parameters('bastionHosts_bastion_name')]",
"location": "[parameters('resourceLocation')]",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('bpublicIPAddressName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
],
"sku": {
"name": "Basic"
},
"properties": {
"dnsName": "[concat(parameters('bastionHosts_bastion_name'), '.azure.com')]",
"ipConfigurations": [
{
"name": "IpConf",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('bpublicIPAddressName'))]"
},
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), 'AzureBastionSubnet')]"
}
}
}
]
}
},
{
"type": "Microsoft.DBforMySQL/servers",
"apiVersion": "2017-12-01-preview",
"name": "[parameters('mySqlServername')]",
"location": "[parameters('resourceLocation')]",
"sku": {
"name": "GP_Gen5_2",
"tier": "GeneralPurpose",
"family": "Gen5",
"size": "5120",
"capacity": 2
},
"properties": {
"createMode": "Default",
"version": "5.7",
"administratorLogin": "[parameters('mySqlAdminName')]",
"administratorLoginPassword": "[parameters('mySqlAdminPass')]",
"sslEnforcement": "Disabled"
},
"resources": [
{
"type": "Microsoft.DBforMySQL/servers/databases",
"apiversion": "2017-12-01",
"name": "[concat(parameters('mySqlServername'), '/', parameters('mysqlDBName'))]",
"dependsOn": [
"[resourceId('Microsoft.DBforMySQL/servers', parameters('mySqlServername'))]"
],
"properties": {
"charset": "utf8",
"collation": "utf8_general_ci"
}
}
]
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2020-12-01",
"name": "[variables('appContainerizationToolServer')]",
"location": "[parameters('resourceLocation')]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces', variables('tnicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "Standard_DS1_v2"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-Datacenter",
"version": "latest"
},
"osDisk": {
"osType": "Windows",
"name": "[concat(variables('appContainerizationToolServer'), '_OsDisk_1_f8ecd33591214460b39574be24c69583')]",
"createOption": "FromImage",
"caching": "ReadWrite",
"managedDisk": {
"storageAccountType": "Premium_LRS"
},
"diskSizeGB": 127
},
"dataDisks": [
{
"lun": 1,
"name": "[concat(variables('appContainerizationToolServer'), '_DataDisk_1')]",
"createOption": "Empty",
"caching": "None",
"writeAcceleratorEnabled": false,
"managedDisk": {
"storageAccountType": "Premium_LRS"
},
"diskSizeGB": 32,
"toBeDetached": false
}
]
},
"osProfile": {
"computerName": "toolclient",
"adminUsername": "adminuser",
"adminPassword": "[parameters('vmAdminPasswordOrKey')]",
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true,
"patchSettings": {
"patchMode": "AutomaticByOS",
"enableHotpatching": false
}
},
"secrets": [],
"allowExtensionOperations": true
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('tnicName'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true
}
}
},
"resources": [
{
"name": "SetupLabVm",
"type": "extensions",
"apiVersion": "2020-06-01",
"location": "[parameters('resourceLocation')]",
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"protectedSettings": {},
"typeHandlerVersion": "1.9",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": ["[concat(parameters('vmTCCustomScriptUri'), parameters('vmTCCustomScriptFileName'))]"],
"commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -File ', parameters('vmTCCustomScriptFileName'))]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines/', variables('appContainerizationToolServer'))]"
]
}
]
},
{
"type": "Microsoft.DBforMySQL/servers/firewallRules",
"apiVersion": "2017-12-01-preview",
"name": "[concat(parameters('mySqlServername'), '/AllowAllWindowsAzureIps')]",
"dependsOn": [
"[resourceId('Microsoft.DBforMySQL/servers', parameters('mySqlServername'))]"
],
"properties": {
"startIpAddress": "0.0.0.0",
"endIpAddress": "0.0.0.0"
}
},
{
"type": "Microsoft.DBforMySQL/servers/firewallRules",
"apiVersion": "2017-12-01-preview",
"name": "[concat(parameters('mySqlServername'), '/AllowAllWindowsDevIps')]",
"dependsOn": [
"[resourceId('Microsoft.DBforMySQL/servers', parameters('mySqlServername'))]"
],
"properties": {
"startIpAddress": "0.0.0.0",
"endIpAddress": "255.255.255.255"
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('lvmName'),'/installscript')]",
"apiVersion": "2019-07-01",
"location": "[parameters('resourceLocation')]",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines', variables('lvmName'))]",
"[resourceId('Microsoft.DBforMySQL/servers', parameters('mySqlServername'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"protectedSettings": {
"commandToExecute": "[
concat('sh setup-vm.sh',' ',
parameters('vmAdminUsername'), ' ',
parameters('javaPackageName'),' ',
parameters('tomcatPackageName'), ' ',
parameters('tomcatServiceFile'), ' ',
parameters('tomcatUsersFile'), ' ',
parameters('tomcatServerConf'), ' ',
parameters('tomcatManagerContext'), ' ',
parameters('tomcatHostManagerContext'), ' ',
parameters('airsonicPackageName'), ' ',
parameters('tomcatContext'), ' ',
parameters('mysqlDriverName'), ' ',
parameters('mysqlClientPackage'), ' ',
concat(parameters('mysqlAdminName'), '@', parameters('mySqlServername')), ' ',
concat('''', parameters('mysqlAdminPass'), ''''), ' ',
concat(parameters('mySqlServername'), '.mysql.database.azure.com'), ' ',
parameters('mysqlDBName')
)
]",
"fileUris": [
"[uri(parameters('_artifactsLocation'), concat('setup-vm.sh', parameters('_artifactsLocationSasToken')))]",
"[uri(parameters('_artifactsLocation'), concat('java-tomcat-install.sh', parameters('_artifactsLocationSasToken')))]",
"[uri(parameters('_artifactsLocation'), concat('airsonic-install.sh', parameters('_artifactsLocationSasToken')))]",
"[uri(parameters('_artifactsLocation'), concat('mysql-install.sh', parameters('_artifactsLocationSasToken')))]",
"[uri(parameters('_artifactsLocation'), concat('mysql-bind.sh', parameters('_artifactsLocationSasToken')))]"
]
}
}
}
]
}