Reputation: 355
I am currently seeding our Cosmos DB using the Azure API via a C# console application. During this process, I delete and recreate the database to ensure that all pre-existing data is removed (this might not be the best option, but I did not see a truncate all option). Originally, the database has the storage setting set to unlimited as seen below.
However, once I delete and recreate the DB, it changes the storage option to fixed as seen below.
I have been googling around for a fix and all I can find is the ability to add a RequestOptions
to the request that creates the DB. Unfortunately, this only gives me the ability to edit the throughput of the database.
How do I go about changing the storage type when I re-create the database?
UPDATE: Here is how I go about creating the database. The statement is rather trivial which is why I didn't include it in the original post.
try
{
await this.client.DeleteDatabaseAsync(UriFactory.CreateDatabaseUri(environment.Settings.DatabaseName));
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
await this.client.CreateDatabaseIfNotExistsAsync(new Database { Id = environment.Settings.DatabaseName });
Upvotes: 0
Views: 268
Reputation: 764
you have to specify Partition key for creating storage capacity unlimited
var collection = new DocumentCollection
{
Id = collectionName,
DefaultTimeToLive = -1
};
collection.PartitionKey.Paths.Add(partitionKey);
var response = await this.cosmosDbClient.CreateDocumentCollectionIfNotExistsAsync(this.databaseUri, collection, new RequestOptions
{
OfferThroughput = offerThroughput
});
Thanks, Shraddha Agrawal
Upvotes: 2