2015-07-21 66 views
3

我创建了一个基于模板的部署,该模板部署过量配置了多个Linux VM。我想根据经典实例自动调整它们,Azure会根据CPU负载打开/关闭实例。以模板方式在ARM模式下自动缩放IaaS VM

这可能与ARM模式?如果没有,是否有建议的替代方法?我能找到的唯一例子是使用Application Insights和PaaS功能。我有一个在Ubuntu主机上运行Docker的Python应用程序。

回答

0

为此,您首先需要为VM创建一个可用性组。在ARM模板的资源decleration看起来是这样的:

{ 
"type": "Microsoft.Compute/availabilitySets", 
    "name": "[variables('availabilitySetName')]", 
    "apiVersion": "2015-05-01-preview", 
    "location": "[parameters('location')]", 
    "properties": { 
     "platformFaultDomainCount": "2" 
    } 
} 

然后虚拟机资源在ARM模板的decliration会是这个样子:

{ 
      "apiVersion": "2015-05-01-preview", 
      "type": "Microsoft.Compute/virtualMachines", 
      "name": "[concat(variables('vmName'), '0')]", 
      "location": "[parameters('location')]", 
      "dependsOn": [ 
       "[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]", 
       "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'), '0')]", 
       "[concat('Microsoft.Compute/availabilitySets/', variables('availabilitySetName'))]" 
      ], 
      "properties": { 
       "availabilitySet": { 
        "id": "[resourceId('Microsoft.Compute/availabilitySets', variables('availabilitySetName'))]" 
       }, 
     ...}, 

的quckstart模板是一个很好的ref:https://raw.githubusercontent.com/azure/azure-quickstart-templates/master/201-2-vms-2-FDs-no-resource-loops/azuredeploy.json

在可用性集合中有两个或更多相同大小的VM后,您可以使用microsoft.insights/autoscalesettings配置自动缩放,我相信您在问题中引用了该自动缩放。这是在云服务这样做,将工作类似的PaaS ......像这样:

{ 
     "apiVersion": "2014-04-01", 
     "name": "[concat(variables('vmName'), '-', resourceGroup().name)]", 
     "type": "microsoft.insights/autoscalesettings", 
     "location": "East US", 
     ...}, 

一个非常不错的例子是在这里:https://raw.githubusercontent.com/Azure/azure-quickstart-templates/6abc9f320e39d9d75dffb60846e88ab80d3ff33a/201-web-app-sql-database/azuredeploy.json

我使用门户网站第一,并审查ARMExplorer还设置自动定标以更好地了解我的代码中应该看起来如何。 ARMExplorer在这里:Azure Resource Explorer

+0

感谢您的指点。我确实为我的虚拟机设置了可用性。我没有的是云服务,而是使用一个publicIP和负载均衡器,根据[本文](http://blogs.msdn.com/b/cloud_solution_architect/archive/2015/05/05/creating-azure -vms-with-arm-powershell-cmdlets.aspx),这表明云服务在ARM中已被弃用?当它适用于虚拟机时,您是否有完整的自动缩放节的示例? targetResourceUri指向什么等?感谢您浏览资源管理器的链接,了解这一点非常有用! – Stephen

+0

你在这里评论的问题中找到答案吗? –

1

对于IaaS,您必须使用虚拟机缩放集才能使用自动缩放,否则您需要使用PaaS(Web应用程序)。