Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 3.23 KB

File metadata and controls

59 lines (45 loc) · 3.23 KB
title Use PowerShell to Monitor and Scale an Elastic Pool
description Azure PowerShell example script to monitor and scale an elastic pool in Azure SQL Database
author WilliamDAssafMSFT
ms.author wiassaf
ms.reviewer wiassaf, mathoma
ms.date 06/10/2025
ms.service azure-sql-database
ms.subservice performance
ms.topic sample
ms.custom
sqldbrb=1
devx-track-azurepowershell
ms.devlang powershell

Use PowerShell to monitor and scale an elastic pool in Azure SQL Database

[!INCLUDEappliesto-sqldb]

This PowerShell script example monitors the performance metrics of an elastic pool, 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.

Sample script

[!code-powershell-interactivemain]

Clean up deployment

Use the following command to remove the resource group and all resources associated with it.

Remove-AzResourceGroup -ResourceGroupName $resourcegroupname

Script explanation

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 databases or elastic pools.
New-AzSqlElasticPool Creates an elastic pool.
New-AzSqlDatabase Creates a database in a server.
Get-AzMetric Shows the size usage information for the database.
Set-AzSqlElasticPool Updates elastic pool properties.
Add-AzMetricAlertRule (DeprecateD) Adds or updates an alert rule to automatically monitor metrics in the future. Applies only to classic metric-based alert rules.
Add-AzMetricAlertRuleV2 Adds or updates an alert rule to automatically monitor metrics in the future. Applies only to non-classic metric-based alert rules.
Remove-AzResourceGroup Deletes a resource group including all nested resources.

Related content