Autoscaling Azure SQL Database

守給你的承諾、 提交于 2019-11-29 22:53:39

After digging through the articles in @ErikEJ's answer (Thanks!) I was able to find the following, which appears to be newly published with the release of the Elastic Scale preview:

Changing Database Service Tiers and Performance Levels

The following REST APIs are now newly available as well, which let you do pretty much whatever you want to your databases:

REST API Operations for Azure SQL Databases

And for my original question of scaling service tiers (ex. P1 -> P3 -> P1):

Update Database REST API

With these new developments I am going to assume it's only a matter of time before autoscaling is also available as a simple configuration in the Azure Portal, much like cloud services.

Chinh Phan

Another way to do it is using Azure automation and using run book below:

param
(
    # Desired Azure SQL Database edition {Basic, Standard, Premium}
    [parameter(Mandatory=$true)] 
    [string] $Edition,

    # Desired performance level {Basic, S0, S1, S2, P1, P2, P3}
    [parameter(Mandatory=$true)] 
    [string] $PerfLevel

)

inlinescript
{
    # I only care about 1 DB so, I put it into variable asset and access from here
    $SqlServerName = Get-AutomationVariable -Name 'SqlServerName'
    $DatabaseName = Get-AutomationVariable -Name 'DatabaseName'


    Write-Output "Begin vertical scaling script..."

    # Establish credentials for Azure SQL Database server 
    $Servercredential = new-object System.Management.Automation.PSCredential("yourDBadmin", ("YourPassword" | ConvertTo-SecureString -asPlainText -Force)) 

    # Create connection context for Azure SQL Database server
    $CTX = New-AzureSqlDatabaseServerContext -ManageUrl “https://$SqlServerName.database.windows.net” -Credential $ServerCredential

    # Get Azure SQL Database context
    $Db = Get-AzureSqlDatabase $CTX –DatabaseName $DatabaseName

    # Specify the specific performance level for the target $DatabaseName
    $ServiceObjective = Get-AzureSqlDatabaseServiceObjective $CTX -ServiceObjectiveName "$Using:PerfLevel"

    # Set the new edition/performance level
    Set-AzureSqlDatabase $CTX –Database $Db –ServiceObjective $ServiceObjective –Edition $Using:Edition -Force

    # Output final status message
    Write-Output "Scaled the performance level of $DatabaseName to $Using:Edition - $Using:PerfLevel"
    Write-Output "Completed vertical scale"
}


Ref:
Azure Vertically Scale Runbook
Setting schedule when u want to scale up/down.
For me, I used 2 schedules with input parameters, 1 for scaling up and another one for scaling down.
Hope that help.

Yes, that feature has is available: Azure SQL Database Elastic Scale

https://docs.microsoft.com/en-gb/azure/sql-database/sql-database-elastic-scale-introduction

In some cases the easiest option might be to just run SQL query as described in msdn.

For example:

ALTER DATABASE [database_name] MODIFY (EDITION = 'standard', SERVICE_OBJECTIVE = 'S3', MAXSIZE = 250 GB)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!