gpt4 book ai didi

powershell - 如何通过Powershell启用Azure Cosmos DB预览功能(聚合管道和Mongodbv3.4)?

转载 作者:行者123 更新时间:2023-12-02 23:37:52 25 4
gpt4 key购买 nike

我想通过 AzureRM Powershell 以编程方式启用聚合管道和 MongoDBv3.4 预览功能。

enter image description here

到目前为止,我已尝试通过 Azure ARM 模板和 Set-AzureRmResource 命令执行此操作,但没有成功。

设置-AzureRmResource:

$updateDBProperties = @{
"capabilities" = @(@{"Name" = "EnableAggregationPipeline"}, @{"Name"= "MongoDBv3.4"})
};

# also tried without luck
# $updateDBProperties = @{
# "capabilities" = @("EnableAggregationPipeline", "MongoDBv3.4")
# };

# won't work
Set-AzureRmResource -ResourceType "Microsoft.DocumentDb/databaseAccounts" `
-ApiVersion "2015-04-08" `
-ResourceGroupName "my-resource-group" `
-Name "my-cosmosdb-development" `
-Properties $updateDBProperties

通过 ARM 模板没有运气:

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"cosmosDBName": {
"type": "string"
},
"location": {
"type": "string"
},
"locations": {
"type": "array"
}
},
"variables": {},
"resources": [
{
"name": "[parameters('cosmosDBName')]",
"type": "Microsoft.DocumentDB/databaseAccounts",
"apiVersion": "2015-04-08",
"location": "[parameters('location')]",
"kind": "MongoDB",
"properties": {
"consistencyPolicy": {
"defaultConsistencyLevel": "Session",
"maxIntervalInSeconds": 5,
"maxStalenessPrefix": 100
},
"databaseAccountOfferType": "Standard",
"locations": "[array(parameters('locations'))]",
"capabilities": [
{
"name": "EnableAggregationPipeline"
},
{
"name": "MongoDBv3.4"
}
]
}
}
],
"outputs": {}
}

我们通过Powershell加载上面的arm模板。 Cosmos 数据库已创建,但预览功能未启用:

New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroup -TemplateFile $templateDirectory"/azureCosmosDB.json" -TemplateParameterObject $templateParameterObject -Name $templateParameterObject.cosmosDBName;

最佳答案

我成功通过命令行工具az设置了这些功能:

az cosmosdb update \
--name my-resource-group \
--resource-group my-cosmosdb-deployment \
--capabilities "EnableAggregationPipeline" "MongoDBv3.4"

虽然花了几分钟。希望有帮助!

关于powershell - 如何通过Powershell启用Azure Cosmos DB预览功能(聚合管道和Mongodbv3.4)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50809926/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com