You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure经典云服务(Classic)是否可实现自动纵向扩容?

Auto Vertical Scaling for Azure Classic Cloud Services: Feasible Solutions

Hey there, great question—even though Azure Classic Cloud Services are a legacy deployment model, there are still actionable ways to set up automatic vertical scaling (resizing instance sizes based on performance metrics). Let’s walk through the most reliable approaches:

1. Azure Automation Runbooks + Azure Monitor Alerts

This is the most straightforward method, leveraging Azure's native tools to trigger scaling actions based on metrics like CPU, memory, or disk usage.

Steps to implement:

  • Create an Azure Automation Account: Make sure to enable the Azure Service Management (ASM) module (since Classic Cloud Services rely on the older ASM API, not ARM).
  • Write a PowerShell Runbook: This script handles resizing your cloud service role instances. Here’s a simplified working example:
    # Authenticate to Azure Classic (ASM)
    $connectionName = "AzureClassicRunAsConnection"
    try {
        $servicePrincipalConnection = Get-AutomationConnection -Name $connectionName         
        Add-AzureAccount `
            -ServicePrincipal `
            -TenantId $servicePrincipalConnection.TenantId `
            -ApplicationId $servicePrincipalConnection.ApplicationId `
            -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint 
    }
    catch {
        if (!$servicePrincipalConnection) {
            $ErrorMessage = "Connection $connectionName not found."
            throw $ErrorMessage
        } else{
            Write-Error -Message $_.Exception
            throw $_.Exception
        }
    }
    
    # Resize the target cloud service role
    $cloudServiceName = "YourClassicCloudServiceName"
    $roleName = "YourWebOrWorkerRoleName"
    $newInstanceSize = "Standard_D2_v2" # Replace with your desired instance size
    
    Set-AzureRole `
        -ServiceName $cloudServiceName `
        -RoleName $roleName `
        -Slot "Production" `
        -InstanceSize $newInstanceSize
    
  • Configure Azure Monitor Alerts: Set up alerts for your cloud service’s metrics (e.g., "CPU Percentage > 80% for 15 minutes"). When the alert triggers, link it to your Automation Runbook as an action.

Note: You’ll need to grant the Automation account’s service principal permissions to modify your Classic Cloud Service (via Azure Classic portal or ASM cmdlets).

2. Logic Apps with ASM API Integration

If you prefer a low-code workflow, Azure Logic Apps can orchestrate scaling actions:

  • Use a Monitor Alert trigger to detect sustained high load.
  • Add an Azure Automation Runbook action (reusing the script above) to handle the resize.
  • For more control, you can make direct calls to the Azure Classic Service Management API via HTTP actions (though this requires manual authentication setup with management certificates).

Critical Things to Keep in Mind

  • Deprecation Heads-Up: Azure Classic Cloud Services are on the retirement path, so these solutions are temporary workarounds. I strongly recommend planning a migration to Azure App Service (for web workloads) or Azure Virtual Machine Scale Sets (for custom workloads)—both have built-in, robust auto-scaling capabilities.
  • Downtime Expectation: Vertical scaling requires restarting role instances, so plan for brief downtime. Always test this in your staging slot first before deploying to production.
  • Avoid Thrashing: Set alert thresholds with longer evaluation windows (15-30 minutes) to prevent constant resizing up and down due to temporary load spikes.

内容的提问来源于stack exchange,提问作者Salvatore Calla'

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 13:42:35