Last active
November 2, 2020 12:09
-
-
Save PradeepLoganathan/b2b4a17a6c4c7edcb2fa7abf970f9590 to your computer and use it in GitHub Desktop.
Creating a Cosmos Db database using Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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