适用于 SQL 数据仓库的 PowerShell cmdlet 和 REST APIPowerShell cmdlets and REST APIs for SQL Data Warehouse

可以使用 Azure PowerShell cmdlet 或 REST API 来管理许多 SQL 数据仓库管理任务。Many SQL Data Warehouse administration tasks can be managed using either Azure PowerShell cmdlets or REST APIs. 下面是如何使用 PowerShell 命令自动执行 SQL 数据仓库中的常见任务的一些示例。Below are some examples of how to use PowerShell commands to automate common tasks in your SQL Data Warehouse. 如需一些好的 REST 示例,请参阅 使用 REST 管理可伸缩性一文。For some good REST examples, see the article Manage scalability with REST.

Note

本文进行了更新,以便使用新的 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
    Get-AzSubscription
    Select-AzSubscription -SubscriptionName "MySubscription"
    

暂停 SQL 数据仓库示例Pause SQL 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
$resultDatabase

启动 SQL 数据仓库示例Start SQL 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

Note

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

其他支持的 PowerShell cmdletOther supported PowerShell cmdlets

Azure SQL 数据仓库支持以下 PowerShell cmdlet。These PowerShell cmdlets are supported with Azure SQL Data Warehouse.

后续步骤Next steps

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

有关可使用 PowerShell 自动执行的其他列表,请参阅 Azure SQL 数据库 CmdletFor other tasks which can be automated with PowerShell, see Azure SQL Database Cmdlets. 请注意,Azure SQL 数据仓库并非支持全部 Azure SQL 数据库 cmdlet。Note that not all Azure SQL Database cmdlets are supported for Azure SQL Data Warehouse. 有关可以使用 REST 自动执行的任务的列表,请参阅 Azure SQL 数据库的操作For a list of tasks which can be automated with REST, see Operations for Azure SQL Database.