繁体   English   中英

Azure Portal中SQL app如何开启自动缩放

[英]How to enable auto scaling for SQL app in Azure Portal

我希望允许从 Azure 门户中的 SQL 数据库应用程序自动缩放,以便允许它在特定日期增加到 200 个 DTU,然后自动缩减到 20 个。我似乎对如何 go 感到困惑据我所知,我还需要使用 Azure cli。 任何帮助将非常感激。

如果您想按某个计划在 Azure 中扩展 SQL,我建议您使用 PowerShell 脚本和连接到该 Runbook 的计划来准备自动化服务。 此外,您还需要将运行配置为选项。

我个人每天都使用这个脚本来扩展和缩减数据库。

## Authentication
Write-Output ""
Write-Output "------------------------ Authentication ------------------------"
Write-Output "Logging into Azure ..."

$connectionName = "AzureRunAsConnection"
try
{
    # Get the connection "AzureRunAsConnection "
    $servicePrincipalConnection=Get-AutomationConnection -Name $connectionName         

    "Logging in to Azure..."
    Add-AzureRmAccount `
        -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
    }
}

##DB Part

$vCores = 18
$currentTier = "GP_Gen5"
$size = 200
$resourceGroup = ""
$serverName = ""
$databaseName = ""
$db_size = "GP_Gen5_4"

Write-Output "Changing DB type to GP_Gen5_4"

Set-AzureRmSqlDatabase `
               -ServerName $serverName `
               -ResourceGroupName $resourceGroup `
               -DatabaseName $databaseName `
               -RequestedServiceObjectiveName $db_size
#               -RequestedServiceObjectiveName "$currentTier" + "_" + "$vCores"

Write-Output "Writing current DB parameters"

Get-AzureRmSqlDatabase `
               -ServerName $serverName `
               -ResourceGroupName $resourceGroup `
               -DatabaseName $databaseName

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM