title | description | author | ms.author | ms.reviewer | ms.date | ms.service | ms.subservice | ms.topic | ms.custom | ms.devlang | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|
PowerShell: Add an elastic pool to a failover group |
Azure PowerShell example script to create an Azure SQL Database elastic pool, add it to a failover group, and test failover. |
rajeshsetlem |
rsetlem |
wiassaf, mathoma |
07/16/2019 |
azure-sql-database |
high-availability |
sample |
|
powershell |
[!INCLUDEappliesto-sqldb]
This Azure PowerShell script example creates a database in Azure SQL Database, adds it to an elastic pool, creates a failover group, and tests failover.
[!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]
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 databases and elastic pools. |
New-AzSqlServerFirewallRule | Creates a server-level firewall rule for a server. |
New-AzSqlDatabase | Creates a new database. |
New-AzSqlElasticPool | Creates an elastic database pool. |
Set-AzSqlDatabase | Sets properties for a database, or moves an existing database into an elastic pool. |
New-AzSqlDatabaseFailoverGroup | Creates a new failover group. |
Get-AzSqlDatabase | Gets one or more databases. |
Add-AzSqlDatabaseToFailoverGroup | Adds one or more databases to a failover group. |
Get-AzSqlDatabaseFailoverGroup | Gets or lists database failover groups. |
Switch-AzSqlDatabaseFailoverGroup | Executes a failover of a database failover group. |
Remove-AzResourceGroup | Removes a resource group |
For more information on the Azure PowerShell, see Azure PowerShell documentation.
Additional SQL Database PowerShell script samples can be found in the Azure SQL Database PowerShell scripts.