Example #1
0
        private async Task <CosmosContainer> GetContainer()
        {
            try
            {
                await cosmosClient.GetDatabase(SingleTon.getResources("DatabaseId")).CreateContainerIfNotExistsAsync(new ContainerProperties()
                {
                    Id = SingleTon.getResources("ContainerId"), PartitionKeyPath = "/Name", IndexingPolicy = new IndexingPolicy()
                    {
                        Automatic = true, IndexingMode = IndexingMode.Consistent
                    }
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            CosmosContainer container = null;

            try
            {
                container = cosmosClient.GetContainer(SingleTon.getResources("DatabaseId"), SingleTon.getResources("ContainerId"));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(container);
        }
Example #2
0
        public async static Task <string> UploadImage(Stream picture, string name)
        {
            BlobContainerClient blobContainerClient = new BlobContainerClient(SingleTon.getResources("connectionStringBlob"), "images");
            BlobClient          BC = blobContainerClient.GetBlobClient(name);
            await BC.UploadAsync(picture, new BlobHttpHeaders()
            {
                ContentType = "image/jpeg"
            });                                                                                 // a extenstion detecting system should be created

            return(blobContainerClient.GetBlobClient(name).Uri.ToString());
        }
Example #3
0
 private async Task <CosmosDatabase> GetDB()
 {
     try
     {
         await cosmosClient.CreateDatabaseIfNotExistsAsync(SingleTon.getResources("DatabaseId"));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(cosmosClient.GetDatabase(SingleTon.getResources("DatabaseId")));
 }
Example #4
0
 public async Task CreateSQLConnector()
 {
     cosmosClient = new CosmosClient(SingleTon.getResources("EndpointUrl"), SingleTon.getResources("AuthorizationKey"));
     await GetDB();
     await GetContainer();
 }