Skip to content

Latest commit

 

History

History
60 lines (41 loc) · 2.11 KB

File metadata and controls

60 lines (41 loc) · 2.11 KB
title The Azure CLI: Add a database to a failover group
description Use the Azure CLI example script to create a database in Azure SQL Database, add it to an auto-failover group, and test failover.
services sql-database
ms.service sql-database
ms.subservice high-availability
ms.custom sqldbrb=1
ms.devlang azurecli
ms.topic sample
author MashaMSFT
ms.author mathoma
ms.reviewer sstein
ms.date 07/16/2019

Use the Azure CLI to add a database to a failover group

[!INCLUDEappliesto-sqldb]

This Azure CLI script example creates a database in Azure SQL Database, creates a failover group, adds the database to it, and tests failover.

If you choose to install and use the CLI locally, this topic requires that you are running the Azure CLI version 2.0 or later. Run az --version to find the version. If you need to install or upgrade, see Install the Azure CLI.

Sample script

Sign in to Azure

[!INCLUDE quickstarts-free-trial-note]

$subscription = "<subscriptionId>" # add subscription here

az account set -s $subscription # ...or use 'az login'

Run the script

[!code-azurecli-interactivemain]

Clean up deployment

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

az group delete --name $resource

Sample reference

This script uses the following commands. Each command in the table links to command-specific documentation.

Command Description
az sql db Database commands.
az sql failover-group Failover group commands.

Next steps

For more information on the Azure CLI, see Azure CLI documentation.

Additional SQL Database CLI script samples can be found in the Azure SQL Database documentation.