Skip to content

Instantly share code, notes, and snippets.

@PradeepLoganathan
Last active November 2, 2020 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PradeepLoganathan/b2b4a17a6c4c7edcb2fa7abf970f9590 to your computer and use it in GitHub Desktop.
Save PradeepLoganathan/b2b4a17a6c4c7edcb2fa7abf970f9590 to your computer and use it in GitHub Desktop.
Creating a Cosmos Db database using Code
private readonly CosmosClient _cosmosClient;
private CosmosDatabase _database;
private CosmosContainer _container;
private readonly string _databaseId = "thetaDb";
private readonly string _containerId = "CustomerContainer";
public CosmosDriver()
{
_cosmosClient = CosmosDbConnection.Instance;
}
public async Task CreateDatabaseAsync()
{
try
{
this._database = await this._cosmosClient.CreateDatabaseIfNotExistsAsync(_databaseId);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment