azure - 用于检查 Azure Cosmos 中是否启用自动缩放的 PowerShell 脚本

标签 azure powershell azure-cosmosdb

我正在编写一个 powershell 脚本,用于检查 cosmosdb 中是否启用了自动缩放,如果没有,则应该启用自动缩放。我找不到可以让我们检查是否启用自动缩放的 powershell 脚本或命令。我指的是以下文档,其中只有一个启用自动缩放的命令。

https://learn.microsoft.com/en-us/azure/cosmos-db/scripts/powershell/sql/throughput?toc=%2Fpowershell%2Fmodule%2Ftoc.json

最佳答案

您可以通过检查 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/

相关文章:

Azure 数据工厂 - 如何处理来自 Microsoft graph REST 源的 CSV 数据

azure - Get-AzDiagnosticSetting - 操作返回无效状态代码 'Forbidden'

powershell - gci(获取子项)如何打印文件内容?

powershell - 将变量串在一起以清除它们是否可以?

c# - 使用 C# 中的 CosmosDB 和 Microsoft.Azure.Cosmos 在 Azure Functions 上实现单例

azure - 如何重新触发 Azure Cosmos DB 中的 CosmosDBTrigger 事件或在处理事件时出现异常时获取触发的事件

azure - 从 Ubuntu 服务器上传 Azure 文件存储上的备份文件

azure - "Test validations: Expired"在 azure devop 中意味着什么?

powershell - 如何正确测试模拟 CmdLet 的 ErrorVariable 值?

azure - Cosmos DB 中的事件 ID 是什么?