Search code examples
azurepowershellazure-cosmosdbazure-cosmosdb-sqlapiazure-cloud-shell

How to create a Cosmos DB Sql Container with analytical storage enabled using PowerShell?


I am writing a PowerShell script where I need to create multiple Cosmos DB Containers using the SQL api.

I already enable analytical storage when creating the Cosmos DB Account :

New-AzCosmosDBAccount -ResourceGroupName $resourceGroupName `
    -Location $locations -Name $cosmosAccountName `
    -ApiKind $apiKind -EnableAutomaticFailover:$true `
    -DefaultConsistencyLevel $consistencyLevel `
    -MaxStalenessIntervalInSeconds $maxStalenessInterval `
    -MaxStalenessPrefix $maxStalenessPrefix `
    -EnableAnalyticalStorage $true

I then create a Cosmos DB SQL Database and follow by creating the containers. I would like to enable analytical storage using -AnalyticalStorageTtl -1 like this:

New-AzCosmosDBSqlContainer `
    -ResourceGroupName $resourceGroupName `
    -AccountName $cosmosAccountName `
    -DatabaseName $databaseName `
    -Name $cosmosDbContainerName1 `
    -PartitionKeyKind Hash `
    -PartitionKeyPath $partitionKeyPath `
    -AnalyticalStorageTtl -1

But I get an error saying "-AnalyticalStorageTtl -1 is not recognized as a cmdlet[...]". This parameter is not available on the PowerShell cmdlet. However it is available using this Azure CLI command.

Am I missing something or is this parameter not available with the PS cmdlet? Are there any workarounds with PowerShell?


Solution

  • Thanks for reporting this. I checked and this indeed was missed in the Cosmos DB PowerShell cmdlets. A Pull Request has been submitted to correct this and it should appear in the next customer release on Jan 19. --Thanks.