使用Powershell扩展CosmosDB容器

时间:2019-05-17 12:52:29

标签: azure powershell azure-cosmosdb

我正在尝试使用Powershell缩放CosmosDB容器,但在文档中找不到任何内容。我尝试了以下无效的脚本。

<script src='https://cdn.jsdelivr.net/g/lodash@4(lodash.min.js+lodash.fp.min.js)'></script>

任何见解都会受到赞赏。

2 个答案:

答案 0 :(得分:1)

这是一个PS脚本,它将更新SQL(核心)API帐户的数据库或容器上的吞吐量。

# Update RU for an Azure Cosmos DB SQL (Core) API database or container
$resourceGroupName = "myResourceGroup"
$accountName = "mycosmosaccount"
$databaseName = "database1"
$containerName = "container1"
$databaseResourceName = $accountName + "/sql/" + $databaseName + "/throughput"
$containerResourceName = $accountName + "/sql/" + $databaseName + "/" + $containerName + "/throughput"
$throughput = 500
$updateResource = "database" # or "container"

$properties = @{
    "resource"=@{"throughput"=$throughput}
}

if($updateResource -eq "database"){
Set-AzResource -ResourceType "Microsoft.DocumentDb/databaseAccounts/apis/databases/settings" `
    -ApiVersion "2015-04-08" -ResourceGroupName $resourceGroupName `
    -Name $databaseResourceName -PropertyObject $properties
}
elseif($updateResource -eq "container"){
Set-AzResource -ResourceType "Microsoft.DocumentDb/databaseAccounts/apis/databases/containers/settings" `
    -ApiVersion "2015-04-08" -ResourceGroupName $resourceGroupName `
    -Name $containerResourceName -PropertyObject $properties
}
else {
    Write-Host("Must select database or container")
} 

答案 1 :(得分:0)

我已使用它来更新自动化帐户上的Azure CosmosDb(SQL API)集合,但是该cmdlet Set-AzResource超时了-有时它可以工作

Get-AzResource -ResourceType Microsoft.DocumentDB / databaseAccounts

$ containerResourceType =“ Microsoft.DocumentDb / databaseAccounts / apis / databases /容器/设置”

在Runbook中将Set命令与API版本一起使用,但由于“操作因请求超时而失败”而失败。

Set-AzResource -ResourceType $ containerResourceType ***

参考: https://serverfault.com/questions/967942/scaling-cosmosdb-container-using-powershell