Ejemplo n.º 1
0
        public CosmosDBHostedFilesService(IOptions <AzureServicesConfiguration> azureOptions,
                                          IFileStorageService fileStorage)
        {
            if (azureOptions == null)
            {
                throw new ArgumentNullException(nameof(azureOptions));
            }

            if (fileStorage == null)
            {
                throw new ArgumentNullException(nameof(fileStorage));
            }

            this.fileStorage = fileStorage;

            azureConfig = azureOptions.Value;
            Collections.InitCollections(azureConfig.CosmosDBId);

            database = new Database {
                Id = azureConfig.CosmosDBId
            };

            userFilesCollection = new DocumentCollection {
                Id = Collections.Ids.UserFiles
            };

            var cosmosEndpointUri = new Uri(azureConfig.CosmosDBEndpointUrl);

            docClient = new DocumentClient(cosmosEndpointUri, azureConfig.CosmosDBKey);

            initSemaphore = new SemaphoreSlim(1, 1);
        }
Ejemplo n.º 2
0
        private static CloudTable CreateTable()
        {
            var config         = new AzureServicesConfiguration();
            var storageAccount = config.EmailQueueStorageAccount;
            var tableClient    = storageAccount.CreateCloudTableClient();
            var table          = tableClient.GetTableReference("bademail");

            table.CreateIfNotExistsAsync().Wait();
            return(table);
        }
Ejemplo n.º 3
0
        public BlobStorageFileStorageService(IOptions <AzureServicesConfiguration> azureOptions)
        {
            if (azureOptions == null)
            {
                throw new ArgumentNullException(nameof(azureOptions));
            }

            azureConfig   = azureOptions.Value;
            cloudStorage  = CloudStorageAccount.Parse(azureConfig.BlobStorageConnectionString);
            blobClient    = cloudStorage.CreateCloudBlobClient();
            blobContainer = blobClient.GetContainerReference(azureConfig.BlobStorageContainer);

            initSemaphore = new SemaphoreSlim(1, 1);
        }