powershell 是否可以使Azure弹性池自动扩展?

ewm0tg9j  于 2023-08-05  发布在  Shell
关注(0)|答案(2)|浏览(92)

我正在尝试自动扩展我的Azure数据库。我已经找到了一个powershell工作流脚本的一个单一的数据库,它的工作完美。我想知道是否可以自动扩展我的弹性池。我试着重写剧本,但失败了很多次。
下面是脚本:

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" 
    } 
}

字符串
如果可能的话,我希望有人能给我指出一个正确的方向。
非常感谢!!!

toiithl6

toiithl61#

参见https://learn.microsoft.com/en-us/azure/sql-database/scripts/sql-database-monitor-and-scale-pool-powershell
此PowerShell脚本示例监视弹性池的性能指标,将其扩展到更高的性能级别,并针对其中一个性能指标创建警报规则。

PS C:\>Set-AzSqlElasticPool 
    -ResourceGroupName "ResourceGroup01" 
    -ServerName "Server01" 
    -ElasticPoolName "ElasticPool01" 
    -Dtu 1000 
    -DatabaseDtuMax 100 
    -DatabaseDtuMin 20

ResourceId        : /subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/resourcegroup01/providers/Microsoft.Sql/servers/Server01/elasticPools/ElasticPool01
ResourceGroupName : ResourceGroup01
ServerName        : Server01
ElasticPoolName   : ElasticPool01
Location          : Central US
CreationDate      : 8/26/2015 10:00:17 PM
State             : Ready
Edition           : Standard
Dtu               : 200
DatabaseDtuMax    : 100
DatabaseDtuMin    : 20
StorageMB         : 204800
Tags              :

字符串

ltskdhd1

ltskdhd12#

如果您对第三方产品持开放态度,请查看CloudMonix-它具有一项功能,可以通过任何指标和/或日期时间自动缩放弹性池、SQL仓库和SQL Azure数据库。
可以在其中定义“缩放范围”和“缩放调整”。标度范围通常是基于时间的标准,在这些标准之间发生标度(即:对于上午9点到下午5点,最小层是P3,最大层是P5,等等),并且比例调整是基于某种性能指标(DTU > 80或网站上的请求/秒> 50,等等)的层中的增量移动
无需PowerShell

相关问题