title | description | services | ms.service | ms.subservice | ms.custom | ms.devlang | ms.topic | author | ms.author | ms.reviewer | ms.date |
---|---|---|---|---|---|---|---|---|---|---|---|
Use PowerShell to monitor and scale a single database in Azure SQL Database |
Use an Azure PowerShell example script to monitor and scale a single database in Azure SQL Database. |
sql-database |
sql-database |
performance |
sqldbrb=1 |
PowerShell |
sample |
juliemsft |
jrasnick |
sstein |
03/12/2019 |
[!INCLUDEappliesto-sqldb]
This PowerShell script example monitors the performance metrics of a single database, scales it to a higher compute size, and creates an alert rule on one of the performance metrics.
[!INCLUDE quickstarts-free-trial-note] [!INCLUDE updated-for-az] [!INCLUDE cloud-shell-try-it.md]
If you choose to install and use PowerShell locally, this tutorial requires Az PowerShell 1.4.0 or later. If you need to upgrade, see Install Azure PowerShell module. If you are running PowerShell locally, you also need to run Connect-AzAccount
to create a connection with Azure.
[!code-powershell-interactivemain]
Note
For a full list of metrics, see metrics supported. [!TIP] Use Get-AzSqlDatabaseActivity to get the status of database operations and use Stop-AzSqlDatabaseActivity to cancel a database update operation.
Use the following command to remove the resource group and all resources associated with it.
Remove-AzResourceGroup -ResourceGroupName $resourcegroupname
This script uses the following commands. Each command in the table links to command-specific documentation.
Command | Notes |
---|---|
New-AzResourceGroup | Creates a resource group in which all resources are stored. |
New-AzSqlServer | Creates a server that hosts a single database or elastic pool. |
Get-AzMetric | Shows the size usage information for the database. |
Set-AzSqlDatabase | Updates database properties or moves the database into, out of, or between elastic pools. |
Add-AzMetricAlertRule | Sets an alert rule to automatically monitor metrics in the future. |
Remove-AzResourceGroup | Deletes a resource group including all nested resources. |
For more information on Azure PowerShell, see Azure PowerShell documentation.
Additional PowerShell script samples can be found in Azure PowerShell scripts.