我想通过 AzureRM Powershell 以编程方式启用聚合管道和 MongoDBv3.4 预览功能。
到目前为止,我已经尝试通过 Azure ARM 模板和Set-AzureRmResource
命令来做到这一点,但没有成功。
Set-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 db,但未启用预览功能:
New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroup -TemplateFile $templateDirectory"/azureCosmosDB.json" -TemplateParameterObject $templateParameterObject -Name $templateParameterObject.cosmosDBName;