Home > Software design >  When provisioning a Cosmos DB - Gremlin API from PowerShell, is there a way to set the capacity mode
When provisioning a Cosmos DB - Gremlin API from PowerShell, is there a way to set the capacity mode

Time:10-05

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.

CodePudding user response:

Unfortunately, it seems that Azure Powershell's New-AzCosmosDBAccount command does not yet support setting the capacity mode for an Azure Cosmos DB account (as of Azure PowerShell version 6.4.0).

These are all of the arguments that the command currently supports, none of which are suitable:

New-AzCosmosDBAccount
   [-EnableAutomaticFailover]
   [-EnableMultipleWriteLocations]
   [-EnableVirtualNetwork]
   [-FromPointInTimeBackup]
   [-ApiKind <String>]
   [-DisableKeyBasedMetadataWriteAccess]
   [-EnableFreeTier <Boolean>]
   [-Location <String[]>]
   [-LocationObject <PSLocation[]>]
   -ResourceGroupName <String>
   -Name <String>
   [-DefaultConsistencyLevel <String>]
   [-IpRule <String[]>]
   [-MaxStalenessIntervalInSeconds <Int32>]
   [-MaxStalenessPrefix <Int32>]
   [-Tag <Hashtable>]
   [-VirtualNetworkRule <String[]>]
   [-VirtualNetworkRuleObject <PSVirtualNetworkRule[]>]
   [-PublicNetworkAccess <String>]
   [-KeyVaultKeyUri <String>]
   [-EnableAnalyticalStorage <Boolean>]
   [-AsJob]
   [-NetworkAclBypass <String>]
   [-NetworkAclBypassResourceId <String[]>]
   [-ServerVersion <String>]
   [-BackupIntervalInMinutes <Int32>]
   [-BackupRetentionIntervalInHours <Int32>]
   [-BackupPolicyType <String>]
   [-AnalyticalStorageSchemaType <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

CodePudding user response:

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.

  • Related