... string EndPointUri { get; set; } = "https://localhost:8081"; string PrimaryKey { get; set; } = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==";
string DBname { get; set; } = AppUser.DatabaseId;//"wenwang0db";
CosmosClient Cosmos_Client = null;
Database WenWangDB = null;
public async Task StartAccessCosmosDataBase()
{
DatabaseResponse response;
ContainerBase<AppUser>.Partition_Key =
new Microsoft.Azure.Cosmos.PartitionKey( User_Service.TheUser.appUser.GeoLocation.Country );
if(Cosmos_Client == null )
{
try
{
Cosmos_Client = new CosmosClient(EndPointUri, PrimaryKey);
try
{
response = await Cosmos_Client.CreateDatabaseIfNotExistsAsync( DBname );
WenWangDB = response.Database;
}
catch( CosmosException cre )
{
Debug.WriteLine(cre.ToString());
}
}
catch( CosmosException cre )
{
Debug.WriteLine(cre.ToString());
}
catch (Exception e)
{
Exception baseException = e.GetBaseException();
Debug.WriteLine("Error: {0}, Message: {1}", e.Message, baseException.Message);
}
}
}
...