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'

火山引擎 最新活动