我正在编写一个 powershell 脚本,用于检查 cosmosdb 中是否启用了自动缩放,如果没有,则应该启用自动缩放。我找不到可以让我们检查是否启用自动缩放的 powershell 脚本或命令。我指的是以下文档,其中只有一个启用自动缩放的命令。
最佳答案
您可以通过检查 Cmdlet 返回的 $througput
对象的 AutoscaleSettings
来检查容器上是否启用了自动缩放。如果容器将吞吐量设置为“手动”,则自动缩放设置的“MaxThrougput”属性将返回零。
$account = "account-name"
$resourceGroup = "resource-group-name"
$database = "database-name"
$container = "container-name"
$throughput = Get-AzCosmosDBSqlContainerThroughput -ResourceGroupName $resourceGroup `
-AccountName $account -DatabaseName $database -Name $container
$autoscaleSettings = $throughput.AutoscaleSettings
if ($autoscaleSettings.MaxThroughput -eq 0) {
Write-Host "Autoscaling is not set on the container"
} else {
Write-Host "Autoscaling is set on the container"
}
关于azure - 用于检查 Azure Cosmos 中是否启用自动缩放的 PowerShell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72573508/