powershellazure-cosmosdbazure-cosmosdb-gremlinapi

When provisioning a Cosmos DB - Gremlin API from PowerShell, is there a way to set the capacity mode to Serverless?


When I create a Cosmos DB - Gremlin API from the Azure Portal there is an option to set the capacity mode to serverless:

enter image description here

However, when I look through the documentation for doing the same through PowerShell, I cannot find something that can do this.


Solution

  • Here is a way to do this that some folk at Azure sent over:

    $resourceGroupName = "my-rg" 
    $accountLocation = "Central US"
    $accountName = "my-account"
    $failoverLocations = @(
         @{ "locationName"="Central US"; "failoverPriority"=0 }
     )
    $capabilities= @(@{"name"="EnableServerless"},@{"name"="EnableGremlin"})
    $CosmosDBProperties = @{
         "databaseAccountOfferType"="Standard";
         "locations"=$failoverLocations;
         "capabilities"=$capabilities;
     }
    New-AzResource -ResourceType "Microsoft.DocumentDb/databaseAccounts" `
         -ApiVersion "2019-12-12" -ResourceGroupName $resourceGroupName `
         -Location $accountLocation -Name $accountName -PropertyObject $CosmosDBProperties
    

    Note that the cmdlet is New-AzResource not New-AzCosmosDBAccount.