Azure PowerShell samples for Azure SQL Database

The following table includes links to sample Azure PowerShell scripts for Azure SQL Database.

Create a single database and an elastic pool
Create a single database and configure a firewall rule Creates a single Azure SQL database and configures a server-level firewall rule.
Create elastic pools and move pooled databases Creates elastic pools, and moves pooled databases, and changes performance levels.
Configure geo-replication and failover
Configure and failover a single database using active geo-replication Configures active geo-replication for a single Azure SQL database and fails it over to the secondary replica.
Configure and failover a pooled database using active geo-replication Configures active geo-replication for an Azure SQL database in an elastic pool, and fails it over to the secondary replica.
Configure and failover a failover group for a single database (preview) Configures a failover group for an Azure SQL server instance, adds a database to the failover group, and fails it over to the secondary server
Scale a single databases and an elastic pool
Scale a single database Monitors the performance metrics of an Azure SQL database, scales it to a higher performance level and creates an alert rule on one of the performance metrics.
Scale an elastic pool Monitors the performance metrics of an elastic pool, scales it to a higher performance level, and creates an alert rule on one of the performance metrics.
Auditing and threat detection
Configure auditing and threat-detection Configures auditing and threat detection policies for an Azure SQL database.
Restore, copy, and import a database
Restore a database Restores an Azure SQL database from a geo-redundant backup and restores a deleted Azure SQL database to the latest backup.
Copy a database to new server Creates a copy of an existing Azure SQL database in a new Azure SQL server.
Import a database from a bacpac file Imports a database to an Azure SQL server from a bacpac file.