azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

CosmosDB Collection TTL parameter options changed and now can't be set to 'Off' through powershell.

Open diirib opened this issue 8 years ago • 5 comments

Describe the bug There's a new option for TTL in a CosmosDB Collection but there's no way to set it to 'off' now. The documentation says it has to be set to "null", and that way it will be 'off', but I get an error when doing it that way. 0 doesn't work either, since it says it should be a non-zero positive number, or -1 to set it to Off (which is no longer valid).

To Reproduce az cosmosdb collection create -c mycollection -d mydatabase -n myaccount -g myresourcegroup --default-ttl 'null' --partition-key-path "/key" Returns: az cosmosdb collection create: error: argument --default-ttl: invalid int value: 'null'

az cosmosdb collection create -c mycollection -d mydatabase -n myaccount -g myresourcegroup --default-ttl 0 --partition-key-path "/key" Returns: Operation Failed: Invalid Arg {"Errors":["The input defaultTtl '0' is invalid. Ensure to provide a nonzero positive integer less than or equal to '2147483647', or '-1' which means never expire."]}

az cosmosdb collection create -c mycollection -d mydatabase -n myaccount -g myresourcegroup --default-ttl 0 --partition-key-path "/key" Returns: Creates a collection with TTL: On (No default)

Expected behavior According to the documentation, TTL of the collection should be set to 'Off'.

Environment summary az cli 2.0.46 az cosmosdb 0.2.1

Additional context

diirib avatar Oct 08 '18 10:10 diirib

Any updates on this @tjprescott ?

diirib avatar Nov 19 '18 13:11 diirib

@moderakh @dmakwana

tjprescott avatar Nov 20 '18 15:11 tjprescott

Hi, Even I am facing this issue. We have multiple collections and one command to create them. so for some it is set to some value and for some it is On(default) but for the collections which needs to be set to off what value we need to pass? Do we have any update on this or is there any other way we can set it to off?

deepikaak avatar Jan 17 '19 08:01 deepikaak

Hi @diirib thank you for raising this issue. Based on documentation, to disable TTL you need to get the collection resource, remove the TTL field and then replace the collection resource. Right now, this is not possible with the CLI. I am tracking a change that will allow you to pass 0 to turn off TTL (work item 457760). The ETA for this update is July 2019. I will post any updates here.

shurd avatar Jun 20 '19 17:06 shurd

The fix has been merged and will appear in the next CLI released on 7/2.

shurd avatar Jun 27 '19 16:06 shurd