{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "location": { "type": "string", "defaultValue": "[resourceGroup().location]", "metadata": { "description": "Location for the resources." } }, "vmName": { "type": "string", "defaultValue": "myvm", "metadata": { "description": "Name of virtual machine" } }, "adminUsername": { "type": "string", "metadata": { "description": "User Account" } }, "adminPassword": { "type": "securestring", "metadata": { "description": "User Password" } }, "vmSize": { "type": "string", "defaultValue": "Standard_D2_v2", "allowedValues": [ "Standard_D4_v2", "Standard_DS4_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_DS2_v2", "Standard_DS3_v2" ], "metadata": { "description": "Size of the Virtual Machine." } }, "storageAccountName": { "type": "string", "defaultValue": "[concat('storage', uniqueString(resourceGroup().id))]", "metadata": { "description": "Name of the storage account" } }, "storageAccountType": { "type": "string", "defaultValue": "Standard_LRS", "metadata": { "description": "Storage account type" } }, "virtualNetworksName": { "defaultValue": "DemoVnetName", "type": "string" }, "subnetName": { "defaultValue": "DemoSubnet", "type": "string" }, "ubuntuOSVersion": { "type": "string", "defaultValue": "16.04.0-LTS", "allowedValues": [ "14.04.5-LTS", "16.04.0-LTS" ], "metadata": { "description": "The Ubuntu version for the Web Server VM. Allowed values: 14.04.5-LTS, 16.04.0-LTS" } }, "mysqlServerName": { "type": "string", "defaultValue": "[concat('mysqlserver-', uniqueString(resourceGroup().id))]", "metadata": { "description": "Server name of MySQL PaaS, is limited 64 characters. You can visit mysql by @mysqlServerName.mysqldb.chinacloudapi.cn, and manage it by https://manage.windowsazure.cn" } }, "mysqlServerSku": { "type": "string", "defaultValue": "MS2", "allowedValues": [ "MS1", "MS2", "MS3", "MS4", "MS5", "MS6" ], "metadata": { "description": "SKU of Mysql PaaS. Please visit https://www.azure.cn/pricing/details/mysql/" } }, "mysqlServerVersion": { "type": "string", "allowedValues": [ "5.6", "5.7", "5.5" ], "defaultValue": "5.6", "metadata": { "description": "Mysql version of MySQL PaaS" } }, "mysqlDatabaseName": { "type": "string", "defaultValue": "[concat('mysqldb-', uniqueString(resourceGroup().id))]", "metadata": { "description": "Name of MySql Database with 64-characters limit. (Detail: http://dev.mysql.com/doc/refman/5.5/en/identifiers.html)" } }, "mysqlUserName": { "type": "string", "metadata": { "description": "User name of MySql Database with 16-characters limit. To avoid conflict£¬ the end user name is mysqlServerName%mysqlUserName¡£ £¨Detail£ºhttp://dev.mysql.com/doc/refman/5.6/en/user-names.html£©" } }, "mysqlPassword": { "type": "securestring", "metadata": { "description": "Password of user of MySql Database with 64-characters limit. (Detail: http://dev.mysql.com/doc/refman/5.6/en/user-names.html)" } }, "_artifactsLocation": { "type": "string", "metadata": { "description": "The base URI where artifacts required by this template are located." }, "defaultValue": "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/ubuntu-apache-test-page/" }, "_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": "" } }, "variables": { "publicIpNamePrefix": "[concat('PublicIp-', uniquestring(resourceGroup().id))]", "nsgName": "[concat('NSG-', uniquestring(resourceGroup().id))]", "nicNamePrefix": "[concat('NIC-', uniquestring(resourceGroup().id))]", "vmOSDiskId": "[concat('OSdiskid-', uniquestring(resourceGroup().id))]", "vmDataDiskId": "[concat('Datadiskid-', uniquestring(resourceGroup().id))]", "commonApiVersion": "2018-02-01", "testPageMarkup": "[concat('', 'Test Page', '', '

This is a test page.

', '')]", "singleQuote": "'" }, "resources": [ { "apiVersion": "2018-02-01", "type": "Microsoft.Network/publicIPAddresses", "name": "[concat(variables('publicIpNamePrefix'), '-', copyIndex())]", "location": "[parameters('location')]", "scale": null, "sku": { "name": "Basic", "tier": "Regional" }, "properties": { "publicIPAddressVersion": "IPv4", "publicIPAllocationMethod": "Dynamic", "dnsSettings": { "domainNameLabel": "[concat(parameters('vmName'), '-', copyIndex())]" }, "idleTimeoutInMinutes": 4, "ipTags": [ ] }, "copy": { "name": "publicipcopy", "count": 2 } }, { "apiVersion": "2018-02-01", "type": "Microsoft.Network/virtualNetworks", "name": "[parameters('virtualNetworksName')]", "location": "[parameters('location')]", "tags": { }, "scale": null, "properties": { "addressSpace": { "addressPrefixes": [ "10.0.0.0/16" ] }, "dhcpOptions": { "dnsServers": [ ] }, "subnets": [ { "name": "[parameters('subnetName')]", "properties": { "addressPrefix": "10.0.0.0/24" } } ], "virtualNetworkPeerings": [ ], "enableDdosProtection": false, "enableVmProtection": false }, "dependsOn": [ ] }, { "apiVersion": "2018-02-01", "type": "Microsoft.Network/networkSecurityGroups", "name": "[variables('nsgName')]", "location": "[parameters('location')]", "scale": null, "properties": { "securityRules": [ { "name": "SSH", "properties": { "description": "Allows SSH traffic", "protocol": "Tcp", "sourcePortRange": "*", "destinationPortRange": "22", "sourceAddressPrefix": "*", "destinationAddressPrefix": "*", "access": "Allow", "priority": 100, "direction": "Inbound" } }, { "name": "web-rule", "properties": { "description": "Allow Web", "protocol": "Tcp", "sourcePortRange": "*", "destinationPortRange": "80", "sourceAddressPrefix": "Internet", "destinationAddressPrefix": "*", "access": "Allow", "priority": 101, "direction": "Inbound" } } ] } }, { "apiVersion": "2018-02-01", "type": "Microsoft.Network/networkInterfaces", "name": "[concat(variables('nicNamePrefix'), '-', copyIndex())]", "location": "[parameters('location')]", "copy": { "name": "niccopy", "count": 2 }, "scale": null, "properties": { "ipConfigurations": [ { "name": "[concat('ipconfig-', uniquestring(resourceGroup().id))]", "properties": { "primary": true, "privateIPAddress": "[concat('10.0.0.', copyIndex(4))]", "privateIPAllocationMethod": "Dynamic", "publicIPAddress": { "id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('publicIpNamePrefix'), '-', copyIndex()))]" }, "subnet": { "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworksName'), parameters('subnetName'))]" } } } ], "dnsSettings": { "dnsServers": [ ] }, "enableIPForwarding": false, "networkSecurityGroup": { "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]" } }, "dependsOn": [ "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('publicIpNamePrefix'), '-', copyIndex()))]", "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworksName'))]", "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]" ] }, { "apiVersion": "2018-04-01", "type": "Microsoft.Compute/disks", "copy": { "name": "diskCopy", "count": 1 }, "location": "[parameters('location')]", "name": "[variables('vmDataDiskId')]", "properties": { "creationData": { "createOption": "Empty" }, "diskSizeGB": 50 } }, { "apiVersion": "2015-06-15", "type": "Microsoft.Storage/storageAccounts", "name": "[parameters('storageAccountName')]", "location": "[parameters('location')]", "properties": { "accountType": "[parameters('storageAccountType')]" } }, { "type": "Microsoft.MySql/servers", "name": "[parameters('mysqlServerName')]", "apiVersion": "2015-09-01", "location": "[parameters('location')]", "tags": { "displayName": "[parameters('mysqlServerName')]" }, "sku": { "name": "[parameters('mysqlServerSku')]" }, "properties": { "version": "[parameters('mysqlServerVersion')]", "AllowAzureServices": true }, "resources": [ { "name": "AllowAllIpAddresses", "type": "firewallRules", "apiVersion": "2015-09-01", "dependsOn": [ "[concat('Microsoft.MySql/servers/', parameters('mysqlServerName'))]" ], "properties": { "startIpAddress": "0.0.0.0", "endIpAddress": "255.255.255.255" } }, { "name": "[parameters('mysqlUserName')]", "type": "users", "apiVersion": "2015-09-01", "dependsOn": [ "[concat('Microsoft.MySql/servers/', parameters('mysqlServerName'))]" ], "properties": { "password": "[parameters('mysqlPassword')]" } }, { "name": "[parameters('mysqlDatabaseName')]", "type": "databases", "tags": { "displayName": "[parameters('mysqlDatabaseName')]" }, "apiVersion": "2015-09-01", "dependsOn": [ "[concat('Microsoft.MySql/servers/', parameters('mysqlServerName'))]" ], "properties": {}, "resources": [ { "name": "[parameters('mysqlUserName')]", "type": "privileges", "apiVersion": "2015-09-01", "dependsOn": [ "[concat('Microsoft.MySql/servers/', parameters('mysqlServerName'), '/users/', parameters('mysqlUserName'))]", "[concat('Microsoft.MySql/servers/', parameters('mysqlServerName'), '/databases/', parameters('mysqlDatabaseName'))]" ], "properties": { "level": "ReadWrite" } } ] } ] }, { "apiVersion": "2017-12-01", "type": "Microsoft.Compute/virtualMachines", "name": "[parameters('vmName')]", "location": "[parameters('location')]", "tags": { }, "scale": null, "properties": { "hardwareProfile": { "vmSize": "[parameters('vmSize')]" }, "storageProfile": { "imageReference": { "publisher": "Canonical", "offer": "UbuntuServer", "sku": "[parameters('ubuntuOSVersion')]", "version": "latest" }, "osDisk": { "name": "[concat(variables('vmOSDiskId'),'_standard_LRS')]", "createOption": "FromImage", "managedDisk": { "storageAccountType": "Standard_LRS" }, "caching": "ReadWrite", "diskSizeGB": 30 }, "dataDisks": [ { "name": "[variables('vmDataDiskId')]", "lun": 0, "caching": "ReadWrite", "createOption": "Attach", "managedDisk": { "id": "[resourceId('Microsoft.Compute/disks',variables('vmDataDiskId'))]" } } ] }, "osProfile": { "computerName": "[parameters('vmName')]", "adminUsername": "[parameters('adminUsername')]", "adminPassword": "[parameters('adminPassword')]", "secrets": [ ] }, "networkProfile": { "networkInterfaces": [ { "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nicNamePrefix'), '-0'))]", "properties": { "primary": true } }, { "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nicNamePrefix'), '-1'))]", "properties": { "primary": false } } ] }, "diagnosticsProfile": { "bootDiagnostics": { "enabled": true, "storageUri": "[reference(resourceId('Microsoft.Storage/storageAccounts/', parameters('storageAccountName')), '2018-02-01').primaryEndpoints.blob]" } } }, "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]", "[resourceId('Microsoft.Compute/disks',variables('vmDataDiskId'))]", "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nicNamePrefix'), '-0'))]", "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nicNamePrefix'), '-1'))]" ], "resources": [ { "type": "extensions", "name": "[concat(parameters('vmName'), '_configScript')]", "apiVersion": "2016-03-30", "location": "[parameters('location')]", "comments": "To install web system", "dependsOn": [ "[parameters('vmName')]" ], "properties": { "publisher": "Microsoft.Azure.Extensions", "type": "CustomScript", "typeHandlerVersion": "2.0", "autoUpgradeMinorVersion": true, "settings": { "fileUris": [ "[concat(parameters('_artifactsLocation'), '/scripts/prepwebserver.sh', parameters('_artifactsLocationSasToken'))]" ], "commandToExecute": "[concat('sh prepwebserver.sh', ' ', 'True', ' ', variables('singleQuote'), variables('testPageMarkup'), variables('singleQuote'), ' ', 'index.html', ' ', variables('singleQuote'), parameters('ubuntuOSVersion'), variables('singleQuote'))]" }, "protectedSettings": { } } } ] } ], "outputs": { "dataIP": { "value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',concat(variables('publicIpNamePrefix'), '-0')),'2015-06-15').dnsSettings.fqdn]", "type": "string" }, "managerIP": { "value": "[reference(resourceId('Microsoft.Network/publicIPAddresses',concat(variables('publicIpNamePrefix'), '-1')),'2015-06-15').dnsSettings.fqdn]", "type": "string" } } }