| title | Azure CLI script examples |
|---|---|
| titleSuffix | Azure SQL Database & SQL Managed Instance |
| description | Azure CLI script examples to create and manage Azure SQL Database and Azure SQL Managed Instance |
| services | sql-database |
| ms.service | sql-db-mi |
| ms.subservice | service |
| ms.custom | overview-samples, mvc, sqldbrb=2, devx-track-azurecli |
| ms.devlang | azurecli |
| ms.topic | sample |
| author | stevestein |
| ms.author | sstein |
| ms.reviewer | |
| ms.date | 02/03/2019 |
[!INCLUDEappliesto-sqldb-sqlmi]
You can configure Azure SQL Database and SQL Managed Instance by using the Azure CLI.
[!INCLUDE quickstarts-free-trial-note]
[!INCLUDE azure-cli-prepare-your-environment.md]
- This tutorial requires version 2.0 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
The following table includes links to Azure CLI script examples to manage single and pooled databases in Azure SQL Database.
| Area | Description |
|---|---|
| Create databases in Azure SQL Database | |
| Create a single database and configure a firewall rule | Creates an SQL Database and configures a server-level firewall rule. |
| Create elastic pools and move pooled databases | Creates elastic pools, moves pooled databases, and changes compute sizes. |
| Scale databases in Azure SQL Database | |
| Scale a single database | Scales a database in SQL Database to a different compute size after querying the size information for the database. |
| Scale an elastic pool | Scales a SQL elastic pool to a different compute size. |
| Configure geo-replication and failover | |
| Add a single database to a failover group | Creates a database and a failover group, adds the database to the failover group, then tests failover to the secondary server. |
| Configure a failover group for an elastic pool | Creates a database, adds it to an elastic pool, adds the elastic pool to the failover group, then tests failover to the secondary server. |
| Configure and fail over a single database by using active geo-replication | Configures active geo-replication for a database in Azure SQL Database and fails it over to the secondary replica. |
| Configure and fail over a pooled database by using active geo-replication | Configures active geo-replication for a database in an elastic pool, then fails it over to the secondary replica. |
| Auditing and threat detection | |
| Configure auditing and threat-detection | Configures auditing and threat detection policies for a database in Azure SQL Database. |
| Back up, restore, copy, and import a database | |
| Back up a database | Backs up a database in SQL Database to an Azure storage backup. |
| Restore a database | Restores a database in SQL Database from a geo-redundant backup and restores a deleted database to the latest backup. |
| Copy a database to a new server | Creates a copy of an existing database in SQL Database in a new server. |
| Import a database from a BACPAC file | Imports a database to SQL Database from a BACPAC file. |
Learn more about the single-database Azure CLI API.
The following table includes links to Azure CLI script examples for Azure SQL Managed Instance.
| Area | Description |
|---|---|
| Create a SQL Managed Instance | |
| Create a SQL Managed Instance | Creates a SQL Managed Instance. |
| Configure Transparent Data Encryption (TDE) | |
| Manage Transparent Data Encryption in a SQL Managed Instance by using Azure Key Vault | Configures Transparent Data Encryption (TDE) in SQL Managed Instance by using Azure Key Vault with various key scenarios. |
| Configure a failover group | |
| Configure a failover group for SQL Managed Instance | Creates two instances of SQL Managed Instance, adds them to a failover group, and then tests failover from the primary SQL Managed Instance to the secondary SQL Managed Instance. |
For additional SQL Managed Instance examples, see the create, update, move a database, and working with scripts.
Learn more about the SQL Managed Instance Azure CLI API.