powershell - 用于将 SQL Azure 数据库升级到标准和高级服务级别/降级到标准和高级服务级别的脚本

标签 powershell azure azure-sql-database

我有一个 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?)?

感谢您的帮助

奥利弗

最佳答案

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

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

关于powershell - 用于将 SQL Azure 数据库升级到标准和高级服务级别/降级到标准和高级服务级别的脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26491631/

相关文章:

Powershell 没有返回正确的 csv 值

powershell - 通过管道传递多个值

azure - 应用程序洞察日志记录 - 只记录我所说的内容,不记录其他内容

asp.net - 使我的 Controller 数据库调用异步或不异步

sql-server - Azure SQL Server 托管实例

azure-sql-database - SQL Azure 将数据库导出到自己的服务器

powershell - 根据文件名子字符串创建文件夹

python - 从 Azure Function App 通过防火墙访问 Azure Blob 存储

sql - SqlAzureDacpacDeployment 中 SqlAdditionalArguments 的语法是什么

powershell - 从 powershell 脚本中运行 powershell 脚本