适用于 Azure SQL 数据库的 Azure CLI 示例Azure CLI samples for Azure SQL Database

可以使用 Azure CLI 配置 Azure SQL 数据库。Azure SQL Database can be configured using Azure CLI.

如果没有 Azure 订阅,可在开始前创建一个 试用帐户If you don't have an Azure subscription, create a trial account before you begin.

可以在本地安装并使用 CLI,本主题要求运行 Azure CLI 2.0 或更高版本。You can install and use the CLI locally, this topic requires that you are running the Azure CLI version 2.0 or later. 运行 az --version 即可查找版本。Run az --version to find the version. 如需进行安装或升级,请参阅安装 Azure CLIIf you need to install or upgrade, see Install the Azure CLI.

创建单一数据库和弹性池Create a single database and an elastic pool
创建单一数据库和配置防火墙规则Create a single database and configure a firewall rule 创建 Azure SQL 数据库并配置服务器级防火墙规则。Creates an Azure SQL database and configures a server-level firewall rule.
创建弹性池并移动共用数据库Create elastic pools and move pooled databases 创建 SQL 弹性池,移动共用 Azure SQL 数据库,并更改计算大小。Creates SQL elastic pools, moves pooled Azure SQL databases, and changes compute sizes.
缩放单一数据库和弹性池Scale a single database and an elastic pool
缩放单一数据库Scale a single database 在查询数据库的大小信息后,将 Azure SQL 数据库缩放为不同的计算大小。Scales an Azure SQL database to a different compute size after querying the size information for the database.
缩放弹性池Scale an elastic pool 将 SQL 弹性池缩放为不同的计算大小。Scales a SQL elastic pool to a different compute size.
配置异地复制和故障转移Configure geo-replication and failover
将单一数据库添加到故障转移组Add single database to 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 failover a single database using active geo-replication 为 Azure SQL 数据库配置活动异地复制,并将其故障转移到辅助副本。Configures active geo-replication for an Azure SQL database and fails it over to the secondary replica.
配置共用数据库并使用活动异地复制对其进行故障转移Configure and failover a pooled database using active geo-replication 为 SQL 弹性池中的 Azure SQL 数据库配置活动异地复制,然后将其故障转移到辅助副本。Configures active geo-replication for an Azure SQL database in a SQL elastic pool, then fails it over to the secondary replica.
审核和威胁检测Auditing and threat detection
配置审核和威胁检测Configure auditing and threat-detection 为 Azure SQL 数据库配置审核和威胁检测策略。Configures auditing and threat detection policies for an Azure SQL database.
备份、还原、复制和导入数据库Backup, restore, copy, and import a database
备份数据库Backup a database 将 Azure SQL 数据库备份到 Azure 存储备份。Backs up an Azure SQL database to an Azure storage backup.
还原数据库Restore a database 从异地冗余备份中还原 Azure SQL 数据库以及将已删除的 Azure SQL 数据库还原到最新备份。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 在新的 Azure SQL 服务器中创建现有 Azure SQL 数据库的副本。Creates a copy of an existing Azure SQL database in a new Azure SQL server.
从 bacpac 文件导入数据库Import a database from a bacpac file 通过 .bacpac 文件将数据库导入到 Azure SQL 服务器。Imports a database to an Azure SQL server from a .bacpac file.

详细了解单一数据库 Azure CLI APILearn more about the single database Azure CLI API.