powershell - 是否可以自动制作天蓝色弹性泳池秤?

标签 powershell azure-sql-database azure-automation

如标题所示,我正在尝试自动扩展Azure数据库。我已经找到了用于单个数据库的Powershell工作流脚本,该脚本运行良好。我想知道是否可以自动缩放 flex 池。我试图重写脚本,但失败多次。

这是下面的脚本:

workflow Set-AzureSqlDatabaseEdition 
{ 
    param 
    ( 
        # Name of the Azure SQL Database server (Ex: bzb98er9bp) 
        [parameter(Mandatory=$true)]  
        [string] $SqlServerName, 

        # Target Azure SQL Elastic Pool
        [parameter(Mandatory=$true)]  
        [string] $ElasticPoolName, 

        # Desired Azure SQL Elastic Pool edition {Basic, Standard, Premium} 
        [parameter(Mandatory=$true)]  
        [string] $Edition, 

        # Desired DTU 
        [parameter(Mandatory=$true)]  
        [string] $DTU, 

        # DatabaseDtuMin  
        [parameter(Mandatory=$true)]
        [string] $DatabaseDtuMin,

        # DatabaseDtuMax
        [parameter(Mandatory=$true)]
        [string] $DatabaseDtuMax,

        # Credentials for $SqlServerName stored as an Azure Automation credential asset 
        # When using in the Azure Automation UI, please enter the name of the credential asset for the "Credential" parameter 
        [parameter(Mandatory=$true)]  
        [PSCredential] $Credential 
    ) 

    inlinescript 
    { 
        Write-Output "Begin vertical scaling script..." 

        # Establish credentials for Azure SQL Database server  
        $Servercredential = new-object System.Management.Automation.PSCredential($Using:Credential.UserName, (($Using:Credential).GetNetworkCredential().Password | ConvertTo-SecureString -asPlainText -Force))  

        # Create connection context for Azure SQL Database server 
        $CTX = New-AzureSqlDatabaseServerContext -ManageUrl “https://$Using:SqlServerName.database.windows.net” -Credential $ServerCredential 

        # Get Azure Elastic Pool context 
        $EP = Get-AzureRmSqlElasticPool $CTX ElasticPoolName $Using:ElasticPoolName 

        # Specify the specific performance level for the target $DatabaseName 
        $DTU = Get-AzureRmSqlElasticPool $CTX ElasticPoolName $Using:DTU 

        # Set the new edition/performance level 
        Set-AzureRmSqlElasticPool $CTX ElasticPoolName $DTU –ServiceObjective $DTU –Edition $Using:Edition -Force 

        # Output final status message 
        Write-Output "Scaled the performance level of $Using:DatabaseName to $Using:Edition - $Using:PerfLevel" 
        Write-Output "Completed vertical scale" 
    } 
}

我希望有人能为我指明正确的方向,以便做到这一点。

非常感谢!!!

最佳答案

如果您愿意使用第三方产品,请查看CloudMonix-它具有一项功能,可以按任何度量标准和/或日期时间自动缩放 flex 池,SQL Warehouse和SQL Azure数据库。

您可以在其中定义比例范围和比例调整。比例范围通常是基于时间的标准,在这两个标准之间会进行比例缩放(例如,对于上午9点至下午5点,最小等级为P3,最大等级为P5,依此类推),并且比例调整是基于某种性能指标(DTU> 80或网站上的“请求/秒”> 50,依此类推)

无需PowerShell

关于powershell - 是否可以自动制作天蓝色弹性泳池秤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50813099/

相关文章:

powershell - 如何在 Powershell 中指定复杂的发布者名称?

powershell - ForEach-Object cmdlet 在管道中的执行顺序是如何工作的?

sql-server - 如何在插入时从 Azure Sql 数据库获取通知

ASP.NET Core 1.1 中的 Azure SetExecutionStrategy

powershell - 尝试从 Azure Runbook 调用 Invoke-RestMethod 时无法连接到远程服务器

c# - System.InvalidOperationException : unknown error: Runtime. 评估抛出异常:通过 C# 使用 Azure 和 Selenium 的 DOMException 错误

regex - 在字符上分割字符串,但加倍的字符是转义符

powershell - 如何使用带有证书身份验证的 powershell 获取 Azure Key Vault secret ?

Azure 门户 SqlAzureExtension 扩展加载失败

Azure 自动化帐户 - 如何使用自定义服务主体进行登录而不是作为帐户运行?