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 PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

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.