Azure Runbook 重命名 SQL 数据库

Azure runbook rename SQL database

在 Azure 中,我想使用 PowerShell 自动化 Runbook 重命名 SQL 数据库,命令如下:

Set-AzureRmSqlDatabase -ResourceGroupName <ResourceGroupName> 
   -ServerName <ServerName> -DatabaseName <DatabaseName> -NewName <NewName>

根据文档https://docs.microsoft.com/en-us/powershell/module/azurerm.sql/set-azurermsqldatabase?view=azurermps-6.13.0

此命令在 Azure 门户顶部导航的 Launch Cloud Shell 中运行良好。

但在 runbook 中,它不起作用并出现此错误:

Set-AzureRmSqlDatabase : A parameter cannot be found that matches parameter name 'NewName'.

运行手册中似乎缺少 -NewName

   Set-AzureRmSqlDatabase `
        -DatabaseName <System.String> `
        -ResourceGroupName <System.String> `
        [-ElasticPoolName <System.String>] `
        [-Tags <System.Collections.Generic.Dictionary`2[System.String,System.String]>] `
        [-RequestedServiceObjectiveName <System.String>] `
        -ServerName <System.String> `
        [-Edition <Microsoft.Azure.Commands.Sql.Database.Model.DatabaseEdition>] `
        [-MaxSizeBytes <System.Int64>]

我希望您是 运行 来自 Azure 自动化帐户的操作手册。

根据您创建 Azure 自动化帐户的时间,您的帐户模块可能已过时。

证明这一点的一个简单方法是创建一个新的运行手册并将其放入其中:

Get-Command Set-AzureRmSqlDatabase

从门户执行 runbook 并查看输出。您会惊讶地看到它会向您报告哪个模块版本。

幸运的是,我有一个非常古老的自动化帐户可以为您证明这一点:

结果:

更新后

结果是: