【问题标题】:Script to upgrade / downgrade SQL Azure Database to /from Standard and Premium service levels用于将 SQL Azure 数据库升级/降级到标准和高级服务级别的脚本
【发布时间】:2014-10-21 16:27:16
【问题描述】:

我有一个 SQL Azure 数据库,它在工作时间需要高级 (P1) 服务级别,但可以在夜间和周末降级到标准 (S2) 以节省成本。

我可以通过 Azure 管理门户毫无问题地执行这些操作,但我想通过预定的 powershell 脚本来执行这些操作。

基本上,我的脚本正在执行以下操作(摘录):

$db = Get-AzureSqlDatabase $serverContext –DatabaseName $dbName
$P1 = Get-AzureSqlDatabaseServiceObjective $serverContext -ServiceObjectiveName "P1"
Set-AzureSqlDatabase $serverContext –Database $db –ServiceObjective $P1 -Force

不幸的是,似乎禁止通过脚本执行此操作:-(

*Set-AzureSqlDatabase : The edition 'Standard' does not support the service objective '7203483a-c4fb-4304-9e9f-17c71c904f5d'.*

有谁知道这是 SQLAzure cmdlet 的限制还是我做错了什么(我通过门户提交相同的请求没有任何问题)。有没有更好的方法来按计划自动执行这些升级/降级操作(REST API?)?

感谢您的帮助

奥利弗

【问题讨论】:

  • 不确定这是否会导致错误,但微软示例中的-ServiceObjectiveName" P1",他们也使用了开关-Edition Premium。这是链接msdn.microsoft.com/en-us/library/azure/dn369872.aspx
  • 谢谢@Paul!真可惜,在对代码进行了多次重构之后,我不知何故忘记了 -Edition 标志! “ P1”中的前导空格不会改变任何内容,但在高级和标准之间切换时 -Edition 标志似乎是强制性的(实际上这很有意义)。不幸的是,我无法将这个答案归功于您
  • 没问题 :) 我已将其添加为答案

标签: powershell azure azure-sql-database


【解决方案1】:

您对Set-AzureSqlDatabase 的调用缺少-Edition 参数。

Set-AzureSqlDatabase $serverContext –Database $db –ServiceObjective $P1 -Force -Edition Premium

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-03
    • 2015-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多