Azure Synapse Analytics 中适用于专用 SQL 池(以前称为 SQL DW)的 PowerShell 和 REST APIPowerShell & REST APIs for for dedicated SQL pool (formerly SQL DW) in Azure Synapse Analytics

许多专用 SQL 池管理任务可以使用 Azure PowerShell cmdlet 或 REST API 进行管理。Many dedicated SQL pool administrative tasks can be managed using either Azure PowerShell cmdlets or REST APIs. 下面是演示如何使用 PowerShell 命令自动执行专用 SQL 池(以前称为 SQL DW)中的常见任务的一些示例。Below are some examples of how to use PowerShell commands to automate common tasks in your dedicated SQL pool (formerly SQL DW). 如需一些好的 REST 示例,请参阅使用 REST 管理可伸缩性一文。For some good REST examples, see the article Manage scalability with REST.


本文已经过更新,以便使用 Azure Az PowerShell 模块。This article has been updated to use the Azure Az PowerShell module. 若要与 Azure 交互,建议使用的 PowerShell 模块是 Az PowerShell 模块。The Az PowerShell module is the recommended PowerShell module for interacting with Azure. 若要开始使用 Az PowerShell 模块,请参阅安装 Azure PowerShellTo get started with the Az PowerShell module, see Install Azure PowerShell. 若要了解如何迁移到 Az PowerShell 模块,请参阅 将 Azure PowerShell 从 AzureRM 迁移到 AzTo learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.

Azure PowerShell cmdlet 入门Get started with Azure PowerShell cmdlets

  1. 打开 Windows PowerShell。Open Windows PowerShell.

  2. 在 PowerShell 提示符下,运行以下命令以登录到 Azure Resource Manager,并选择用户的订阅。At the PowerShell prompt, run these commands to sign in to the Azure Resource Manager and select your subscription.

    Connect-AzAccount -Environment AzureChinaCloud
    Select-AzSubscription -SubscriptionName "MySubscription"

暂停数据仓库示例Pause data warehouse example

暂停名为“Server01”的服务器上托管的名为“Database02”的数据库。Pause a database named "Database02" hosted on a server named "Server01." 该服务器位于名为“ResourceGroup1”的 Azure 资源组中。The server is in an Azure resource group named "ResourceGroup1."

Suspend-AzSqlDatabase -ResourceGroupName "ResourceGroup1" -ServerName "Server01" -DatabaseName "Database02"

作为一种变体,此示例通过管道将检索到的对象传递给 Suspend-AzSqlDatabaseA variation, this example pipes the retrieved object to Suspend-AzSqlDatabase. 因此会暂停该数据库。As a result, the database is paused. 最后一个命令显示结果。The final command shows the results.

$database = Get-AzSqlDatabase -ResourceGroupName "ResourceGroup1" -ServerName "Server01" -DatabaseName "Database02"
$resultDatabase = $database | Suspend-AzSqlDatabase

启动数据仓库示例Start data warehouse example

恢复“Server01”的服务器上托管的“Database02”数据库的运行。Resume operation of a database named "Database02" hosted on a server named "Server01." 该服务器包含在名为“ResourceGroup1”的资源组中。The server is contained in a resource group named "ResourceGroup1."

Resume-AzSqlDatabase -ResourceGroupName "ResourceGroup1" -ServerName "Server01" -DatabaseName "Database02"

作为一种变体,此示例可从“ResourceGroup1”资源组包含的“Server01”服务器中检索“Database02”数据库。A variation, this example retrieves a database named "Database02" from a server named "Server01" that is contained in a resource group named "ResourceGroup1." 它通过管道将检索到的对象传递给 Resume-AzSqlDatabaseIt pipes the retrieved object to Resume-AzSqlDatabase.

$database = Get-AzSqlDatabase -ResourceGroupName "ResourceGroup1" -ServerName "Server01" -DatabaseName "Database02"
$resultDatabase = $database | Resume-AzSqlDatabase


注意,如果服务器是,请使用“foo”作为 PowerShell cmdlet 中的 -ServerName。Note that if your server is, use "foo" as the -ServerName in the PowerShell cmdlets.

其他支持的 PowerShell cmdletOther supported PowerShell cmdlets

Azure Synapse Analytics 数据仓库支持这些 PowerShell cmdlet。These PowerShell cmdlets are supported with Azure Synapse Analytics data warehouse.

后续步骤Next steps

有关更多的 PowerShell 示例,请参阅:For more PowerShell examples, see:

若要了解其他可使用 PowerShell 自动执行的任务,请参阅 Azure SQL 数据库 cmdletFor other tasks that can be automated with PowerShell, see Azure SQL Database cmdlets. Azure Synapse Analytics 数据仓库并非支持所有 Azure SQL 数据库 cmdlet。Not all Azure SQL Database cmdlets are supported for Azure Synapse Analytics data warehouse. 有关可以使用 REST 自动执行的任务列表,请参阅 Azure SQL 数据库的操作For a list of tasks that can be automated with REST, see Operations for Azure SQL Database.