In a few scenarios, you might need to scale multiple databases on a logical server (not part of elastic pool) at once, the azure portal only allows you to scale each database individually. This can be achieved using the following PowerShell script:
just modify the parameters like SubID, the resource group and server name and then pick the service tier you want and run the script:
Connect-AzAccount
Set-AzContext -SubscriptionId "SubID"
$ResourceGroup = "ResourceGroup"
$Server = "SQLServer"
$edition = "Standard"
$ServObjective = "S2"
$Databases = Get-AzSqlDatabase -ResourceGroupName $ResourceGroup -ServerName $Server | Where-Object {$_.DatabaseName -ne "master"} | Select-Object -Property DatabaseName
foreach($DB in $Databases){
Set-AzSqlDatabase -ResourceGroupName $ResourceGroup -DatabaseName $DB.DatabaseName -ServerName $Server -Edition $edition -RequestedServiceObjectiveName $ServObjective}
Note: Be careful with the databases who are part of Geo replication or Failover groups as you need to make sure that the target database is upgraded before the source database.
Any database can be excluded like the master DB above, just add: | Where-Object {$_.DatabaseName -ne "DB name"}
References
Get-AzSqlDatabase (Az.Sql) | Microsoft Learn
Set-AzSqlDatabase (Az.Sql) | Microsoft Learn
Disclaimer
Please note that the products and options presented in this article are subject to change. This article shows how to multiple Azure SQL databases under single server at once in March 2023.
I hope this article was helpful for you. please feel free to share your feedback in the comments section below.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.