2016-03-05 84 views

回答

0

以下是通过Linux VM创建Azure MySQL的ARM模板。您可以根据自己的需求进行定制。

{ 
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 
    "contentVersion": "1.0.0.0", 
    "parameters": { 
    "mysqlPassword": { 
     "type": "securestring", 
     "metadata": { 
     "description": "Root password password for the MySQL database." 
     } 
    }, 
    "adminUsername": { 
     "type": "string", 
     "metadata": { 
     "description": "Username for the Virtual Machine." 
     } 
    }, 
    "adminPassword": { 
     "type": "securestring", 
     "metadata": { 
     "description": "Password for the Virtual Machine." 
     } 
    }, 
    "sku": { 
     "type": "string", 
     "allowedValues": [ 
     "Free", 
     "Shared", 
     "Basic", 
     "Standard", 
     "Premium" 
     ], 
     "defaultValue": "Free", 
     "metadata": { 
     "description": "The pricing tier for the App Service plan." 
     } 
    }, 
    "svcPlanSize": { 
     "type": "string", 
     "defaultValue": "F1", 
     "metadata": { 
     "description": "The instance size of the app." 
     } 
    }, 
    "prefix": { 
     "type": "string", 
     "metadata": { 
     "description": "Prefix for all the resources." 
     } 
    } 
    }, 
    "variables": { 
    "imagePublisher": "Canonical", 
    "imageOffer": "UbuntuServer", 
    "ubuntuOSVersion": "15.10", 
    "OSDiskName": "osdiskfordockersimple", 
    "nsgName": "[concat(parameters('prefix'),'NSG')]", 
    "nicName": "[concat(parameters('prefix'),'VMNic')]", 
    "dnsNameForPublicIP": "[parameters('prefix')]", 
    "extensionName": "DockerExtension", 
    "addressPrefix": "10.0.0.0/16", 
    "subnetName": "Subnet", 
    "subnetPrefix": "10.0.0.0/24", 
    "storageAccountType": "Standard_LRS", 
    "storageName": "wpac", 
    "publicIPAddressName": "[concat(parameters('prefix'),'PublicIP')]", 
    "publicIPAddressType": "Dynamic", 
    "serverFarmName": "[concat(parameters('prefix'),'SrvFrm')]", 
    "vmStorageAccountContainerName": "vhds", 
    "vmName": "[concat(parameters('prefix'),'DockerVM')]", 
    "vmSize": "Basic_A1", 
    "virtualNetworkName": "[concat(parameters('prefix'),'VNET')]", 
    "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]", 
    "nsgID": "[resourceId('Microsoft.Network/networkSecurityGroups',variables('nsgName'))]", 
    "subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]", 
    "webAppName": "[concat(parameters('prefix'),'WebApp')]" 
    }, 
    "resources": [ 
    { 
     "type": "Microsoft.Storage/storageAccounts", 
     "name": "[variables('storageName')]", 
     "apiVersion": "2015-05-01-preview", 
     "location": "[resourceGroup().location]", 
     "properties": { 
     "accountType": "[variables('storageAccountType')]" 
     } 
    }, 
    { 
     "apiVersion": "2015-05-01-preview", 
     "type": "Microsoft.Network/publicIPAddresses", 
     "name": "[variables('publicIPAddressName')]", 
     "location": "[resourceGroup().location]", 
     "properties": { 
     "publicIPAllocationMethod": "[variables('publicIPAddressType')]", 
     "dnsSettings": { 
      "domainNameLabel": "[variables('dnsNameForPublicIP')]" 
     } 
     } 
    }, 
    { 
     "apiVersion": "2015-05-01-preview", 
     "type": "Microsoft.Network/virtualNetworks", 
     "name": "[variables('virtualNetworkName')]", 
     "location": "[resourceGroup().location]", 
     "dependsOn": [ 
     "[variables('nsgID')]" 
     ], 
     "properties": { 
     "addressSpace": { 
      "addressPrefixes": [ 
      "[variables('addressPrefix')]" 
      ] 
     }, 
     "subnets": [ 
      { 
      "name": "[variables('subnetName')]", 
      "properties": { 
       "addressPrefix": "[variables('subnetPrefix')]", 
       "networkSecurityGroup": { 
       "id": "[variables('nsgID')]" 
       } 
      } 
      } 
     ] 
     } 
    }, 
    { 
     "apiVersion": "2015-05-01-preview", 
     "type": "Microsoft.Network/networkInterfaces", 
     "name": "[variables('nicName')]", 
     "location": "[resourceGroup().location]", 
     "dependsOn": [ 
     "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", 
     "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" 
     ], 
     "properties": { 
     "ipConfigurations": [ 
      { 
      "name": "ipconfig1", 
      "properties": { 
       "privateIPAllocationMethod": "Dynamic", 
       "publicIPAddress": { 
       "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]" 
       }, 
       "subnet": { 
       "id": "[variables('subnetRef')]" 
       } 
      } 
      } 
     ] 
     } 
    }, 
    { 
     "apiVersion": "2015-05-01-preview", 
     "type": "Microsoft.Network/networkSecurityGroups", 
     "name": "[variables('nsgName')]", 
     "location": "[resourceGroup().location]", 
     "properties": { 
     "securityRules": [ 
      { 
      "name": "mysql", 
      "properties": { 
       "description": "Allow MySQL", 
       "protocol": "Tcp", 
       "sourcePortRange": "*", 
       "destinationPortRange": "3306", 
       "sourceAddressPrefix": "Internet", 
       "destinationAddressPrefix": "*", 
       "access": "Allow", 
       "priority": 100, 
       "direction": "Inbound" 
      } 
      }, 
      { 
      "name": "ssh", 
      "properties": { 
       "description": "Allow SSH", 
       "protocol": "Tcp", 
       "sourcePortRange": "*", 
       "destinationPortRange": "22", 
       "sourceAddressPrefix": "Internet", 
       "destinationAddressPrefix": "*", 
       "access": "Allow", 
       "priority": 110, 
       "direction": "Inbound" 
      } 
      } 
     ] 
     } 
    }, 
    { 
     "apiVersion": "2015-05-01-preview", 
     "type": "Microsoft.Compute/virtualMachines", 
     "name": "[variables('vmName')]", 
     "location": "[resourceGroup().location]", 
     "dependsOn": [ 
     "[concat('Microsoft.Storage/storageAccounts/', variables('storageName'))]", 
     "[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('ubuntuOSVersion')]", 
      "version": "latest" 
      }, 
      "osDisk": { 
      "name": "osdisk1", 
      "vhd": { 
       "uri": "[concat('http://',variables('storageName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('OSDiskName'),'.vhd')]" 
      }, 
      "caching": "ReadWrite", 
      "createOption": "FromImage" 
      } 
     }, 
     "networkProfile": { 
      "networkInterfaces": [ 
      { 
       "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]" 
      } 
      ] 
     } 
     } 
    }, 
    { 
     "type": "Microsoft.Compute/virtualMachines/extensions", 
     "name": "[concat(variables('vmName'),'/', variables('extensionName'))]", 
     "apiVersion": "2015-05-01-preview", 
     "location": "[resourceGroup().location]", 
     "dependsOn": [ 
     "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]" 
     ], 
     "properties": { 
     "publisher": "Microsoft.Azure.Extensions", 
     "type": "DockerExtension", 
     "typeHandlerVersion": "1.1", 
     "autoUpgradeMinorVersion": true, 
     "settings": { 
      "compose": { 
      "db": { 
       "image": "mysql", 
       "ports": [ 
       "3306:3306" 
       ], 
       "volumes": [ 
       "/var/lib/mysql:/var/lib/mysql" 
       ], 
       "environment": [ 
       "[concat('MYSQL_ROOT_PASSWORD=', parameters('mysqlPassword'))]", 
       "MYSQL_DATABASE=wpacMySQL", 
       "[concat('MYSQL_USER=', parameters('adminUsername'))]", 
       "[concat('MYSQL_PASSWORD=', parameters('mysqlPassword'))]" 
       ] 
      } 
      } 
     } 
     } 
    }, 
    { 
     "type": "Microsoft.Web/serverfarms", 
     "apiVersion": "2015-08-01", 
     "name": "[variables('serverFarmName')]", 
     "location": "[resourceGroup().location]", 
     "sku": { 
      "name": "[parameters('svcPlanSize')]", 
      "tier": "[parameters('sku')]", 
      "capacity": 1 
     } 
    } 
    ] 
} 
+0

感谢您的帮助。但是我需要一个独立的Azure,我的SQL数据库不在VM中。请给我一些想法。 –