[英]Autoscaling IaaS VMs in ARM mode from a template
我已經創建了一個基於模板的部署,它過度配置了許多Linux VM。 我想根據經典實例自動調整它們,Azure將根據CPU負載打開/關閉實例。
ARM模式可以實現嗎? 如果沒有,是否有建議的替代方法? 我能找到的唯一例子是使用Application Insights和PaaS功能。 我在Ubuntu主機上的Docker中運行了一個Python應用程序。
對於IaaS,您必須使用虛擬機規模集來使用自動縮放,否則您需要堅持使用PaaS(Web應用程序)。
為此,您首先需要為VM創建可用性組。 ARM模板中的資源解除看起來像這樣:
{
"type": "Microsoft.Compute/availabilitySets",
"name": "[variables('availabilitySetName')]",
"apiVersion": "2015-05-01-preview",
"location": "[parameters('location')]",
"properties": {
"platformFaultDomainCount": "2"
}
}
然后,對於虛擬機資源,ARM模板中的拒絕將如下所示:
{
"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模板是一個很好的參考: 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.