예제 #1
0
 public FailureWhenAddingDocumentToDbCompensation(
     ILogger <FailureWhenAddingDocumentToDbCompensation> logger,
     IBlobStorageClient blobStorageClient
     ) : base(logger)
 {
     _blobStorageClient = blobStorageClient;
 }
예제 #2
0
        private void InitializeServices()
        {
            var fixture = new TestFixture();

            _blobStorageClient = fixture.ServiceProvider.GetRequiredService <IBlobStorageClient>();
            //_starTrekIpsumGenerator = serviceProvider.GetRequiredService<IStarTrekIpsumGenerator>();
        }
예제 #3
0
 public DeleteDocumentFromStorage(
     ILogger <DeleteDocumentFromStorage> logger,
     IBlobStorageClient blobStorageClient
     ) : base(logger)
 {
     _blobStorageClient = blobStorageClient;
 }
예제 #4
0
 public RulesConverter(
     IBlobStorageClient blobClient,
     IStorageAdapterClient storageAdapterClient,
     ILogger <RulesConverter> log)
     : base(blobClient, storageAdapterClient, log)
 {
 }
예제 #5
0
 public DeviceIconRepository(IConfigurationProvider configurationProvider, IBlobStorageClientFactory blobStorageClientFactory)
 {
     _storageAccountConnectionString    = configurationProvider.GetConfigurationSettingValue("device.StorageConnectionString");
     _deviceIconsBlobStoreContainerName = configurationProvider.GetConfigurationSettingValueOrDefault("DeviceIconStoreContainerName", "deviceicons");
     _blobStorageClient = blobStorageClientFactory.CreateClient(_storageAccountConnectionString, _deviceIconsBlobStoreContainerName);
     _writePolicyName   = _deviceIconsBlobStoreContainerName + "-write";
 }
예제 #6
0
 public DocumentContentQueryHandler(
     IQueryDispatcher bus,
     IMapper mapper,
     IBlobStorageClient blobStorageClient,
     ILogger <DocumentContentQuery> logger) : base(bus, mapper, logger)
 {
     _blobStorageClient = blobStorageClient;
 }
 public TenantOperations(ITableStorageClient tableStorageClient, IBlobStorageClient blobStorageClient, IAzureManagementClient azureManagementClient, IAppConfigurationClient appConfigurationClient, AppConfig config)
 {
     this.tableStorageClient     = tableStorageClient;
     this.blobStorageClient      = blobStorageClient;
     this.azureManagementClient  = azureManagementClient;
     this.appConfigurationClient = appConfigurationClient;
     this.config = config;
 }
 public IoTHubMonitor(ITableStorageClient tableStorageClient, IBlobStorageClient blobStorageClient, IAzureManagementClient azureManagementClient, IAppConfigurationClient appConfigurationClient, AppConfig config)
 {
     this.tableStorageClient     = tableStorageClient;
     this.blobStorageClient      = blobStorageClient;
     this.azureManagementClient  = azureManagementClient;
     this.appConfigurationClient = appConfigurationClient;
     this.config = config;
 }
예제 #9
0
        public static void UploadText(this IBlobStorageClient blobStorageClient, string text, string blobName)
        {
            blobStorageClient.Require("blobStorageClient");
            text.Require("text");
            blobName.Require("blobName");

            blobStorageClient.UploadBlob(new MemoryStream(Encoding.UTF8.GetBytes(text)), blobName);
        }
예제 #10
0
        public static void UploadFile(this IBlobStorageClient blobStorageClient, string filePath, string blobName)
        {
            blobStorageClient.Require("blobStorageClient");
            filePath.Require("filePath");
            blobName.Require("blobName");

            blobStorageClient.UploadBlob(new MemoryStream(File.ReadAllBytes(filePath)), blobName);
        }
예제 #11
0
        public static T DownloadObject <T>(this IBlobStorageClient blobStorageClient, string blobName)
            where T : class
        {
            blobStorageClient.Require("blobStorageClient");
            blobName.Require("blobName");

            return(blobStorageClient.DownloadText(blobName).FromJson <T>());
        }
예제 #12
0
        public void When_uploading_text_should_throw_ArgumentNullException_if_IBlobStorageClient_is_null()
        {
            IBlobStorageClient blobStorageClient = null;
            var ex = Assert.Throws <ArgumentNullException>(() => blobStorageClient.UploadText("Test", BlobName));

            Assert.IsNotNull(ex);
            Assert.AreEqual(ex.ParamName, "blobStorageClient");
        }
 public ActionMappingRepository(IConfigurationProvider configurationProvider, IBlobStorageClientFactory blobStorageClientFactory)
 {
     string blobName = configurationProvider.GetConfigurationSettingValue("ActionMappingStoreBlobName");
     string connectionString = configurationProvider.GetConfigurationSettingValue("device.StorageConnectionString");
     string containerName = configurationProvider.GetConfigurationSettingValue("ActionMappingStoreContainerName");
     _blobName = blobName;
     _blobStorageManager = blobStorageClientFactory.CreateClient(connectionString, containerName);
 }
예제 #14
0
        public void When_downloading_file_should_throw_an_ArgumentNullException_if_IBlobStorageClient_is_null()
        {
            IBlobStorageClient blobStorageClient = null;
            var ex = Assert.Throws <ArgumentNullException>(() => blobStorageClient.DownloadFile("SomeFile.txt", BlobName));

            Assert.IsNotNull(ex);
            Assert.AreEqual(ex.ParamName, "blobStorageClient");
        }
 public DeviceGroupsConverter(
     IIotHubManagerClient iotHubManager,
     IBlobStorageClient blobClient,
     IStorageAdapterClient storageAdapterClient,
     ILogger <DeviceGroupsConverter> log)
     : base(blobClient, storageAdapterClient, log)
 {
     this.iotHubManager = iotHubManager;
 }
예제 #16
0
        public static void UploadObject <T>(this IBlobStorageClient blobStorageClient, T @object, string blobName)
            where T : class
        {
            blobStorageClient.Require("blobStorageClient");
            @object.Require("object");
            blobName.Require("blobName");

            blobStorageClient.UploadText(@object.ToJson(), blobName);
        }
예제 #17
0
 public Converter(
     IBlobStorageClient blobStorageClient,
     IStorageAdapterClient storageAdapterClient,
     ILogger <Converter> logger)
 {
     this.blobStorageClient    = blobStorageClient;
     this.StorageAdapterClient = storageAdapterClient;
     this.Logger = logger;
 }
 public AddDocumentToStorage(
     ILogger <AddDocumentToStorage> logger,
     IBlobStorageClient blobStorageClient,
     IMessageDataRepository messageDataRepository
     ) : base(logger)
 {
     _blobStorageClient     = blobStorageClient;
     _messageDataRepository = messageDataRepository;
 }
        public ActionMappingRepository(IConfigurationProvider configurationProvider, IBlobStorageClientFactory blobStorageClientFactory)
        {
            string blobName         = configurationProvider.GetConfigurationSettingValue("ActionMappingStoreBlobName");
            string connectionString = configurationProvider.GetConfigurationSettingValue("device.StorageConnectionString");
            string containerName    = configurationProvider.GetConfigurationSettingValue("ActionMappingStoreContainerName");

            _blobName           = blobName;
            _blobStorageManager = blobStorageClientFactory.CreateClient(connectionString, containerName);
        }
 public UpdateDocumentInStorage(
     ILogger <UpdateDocumentInStorage> logger,
     IBlobStorageClient blobStorageClient,
     IMessageDataRepository messageDataRepository
     ) : base(logger)
 {
     _blobStorageClient     = blobStorageClient;
     _messageDataRepository = messageDataRepository;
 }
 public IoTHubMonitor(ITableStorageClient tableStorageClient, IBlobStorageClient blobStorageClient, IAzureManagementClient azureManagementClient, IAppConfigurationClient appConfigurationClient, AppConfig config, IKustoTableManagementClient kustoTableManagementClient, IDeviceGroupsConfigClient deviceGroupsConfigClient)
 {
     this.tableStorageClient     = tableStorageClient;
     this.blobStorageClient      = blobStorageClient;
     this.azureManagementClient  = azureManagementClient;
     this.appConfigurationClient = appConfigurationClient;
     this.config = config;
     this.kustoTableManagementClient = kustoTableManagementClient;
     this.deviceGroupClient          = deviceGroupsConfigClient;
 }
예제 #22
0
        public static string DownloadText(this IBlobStorageClient blobStorageClient, string blobName)
        {
            blobStorageClient.Require("blobStorageClient");
            blobName.Require("blobName");

            using (var outputStream = new MemoryStream())
            {
                blobStorageClient.DownloadBlob(blobName).CopyTo(outputStream);
                return(Encoding.UTF8.GetString(outputStream.ToArray()));
            }
        }
예제 #23
0
        public static byte[] DownloadBytes(this IBlobStorageClient blobStorageClient, string blobName)
        {
            blobStorageClient.Require("blobStorageClient");
            blobName.Require("blobName");

            using (var outputStream = new MemoryStream())
            {
                blobStorageClient.DownloadBlob(blobName).CopyTo(outputStream);
                return(outputStream.ToArray());
            }
        }
예제 #24
0
        public static void DownloadFile(this IBlobStorageClient blobStorageClient, string filePath, string blobName)
        {
            blobStorageClient.Require("blobStorageClient");
            filePath.Require("filePath");
            blobName.Require("blobName");

            using (var blobStream = blobStorageClient.DownloadBlob(blobName))
                using (var fileStream = File.Create(filePath))
                {
                    blobStream.CopyTo(fileStream);
                }
        }
        /// <summary>
        /// Initializes a new instance of the AlertsRepository class.
        /// </summary>
        /// <param name="configProvider">
        /// The IConfigurationProvider implementation with which the new 
        /// instance will be initialized.
        /// </param>
        public AlertsRepository(IConfigurationProvider configProvider, IBlobStorageClientFactory blobStorageClientFactory)
        {
            if (configProvider == null)
            {
                throw new ArgumentNullException("configProvider");
            }

            string alertsContainerConnectionString = configProvider.GetConfigurationSettingValue("device.StorageConnectionString");
            string alertsStoreContainerName = configProvider.GetConfigurationSettingValue("AlertsStoreContainerName");
            this._blobStorageManager = blobStorageClientFactory.CreateClient(alertsContainerConnectionString, alertsStoreContainerName);
            this.deviceAlertsDataPrefix = configProvider.GetConfigurationSettingValue("DeviceAlertsDataPrefix");
        }
 public TenantOperations(ITableStorageClient tableStorageClient, IBlobStorageClient blobStorageClient, IAzureManagementClient azureManagementClient, IAppConfigurationClient appConfigurationClient, AppConfig config, IGrafanaClient grafanaClient, IKustoTableManagementClient kustoTableManagementClient, IIdentityGatewayClient identityGatewayClient, IKeyVaultClient keyVaultClient)
 {
     this.tableStorageClient     = tableStorageClient;
     this.blobStorageClient      = blobStorageClient;
     this.azureManagementClient  = azureManagementClient;
     this.appConfigurationClient = appConfigurationClient;
     this.config        = config;
     this.grafanaClient = grafanaClient;
     this.kustoTableManagementClient = kustoTableManagementClient;
     this.identityGatewayClient      = identityGatewayClient;
     this.keyVaultClient             = keyVaultClient;
 }
        /// <summary>
        /// Initializes a new instance of the DeviceTelemetryRepository class.
        /// </summary>
        /// <param name="configProvider">
        /// The IConfigurationProvider implementation with which to initialize 
        /// the new instance.
        /// </param>
        public DeviceTelemetryRepository(IConfigurationProvider configProvider, IBlobStorageClientFactory blobStorageClientFactory)
        {
            if (configProvider == null)
            {
                throw new ArgumentNullException("configProvider");
            }

            string telemetryContainerName = configProvider.GetConfigurationSettingValue("TelemetryStoreContainerName");
            _telemetryDataPrefix = configProvider.GetConfigurationSettingValue("TelemetryDataPrefix");
            string telemetryStoreConnectionString = configProvider.GetConfigurationSettingValue("device.StorageConnectionString");
            _telemetrySummaryPrefix = configProvider.GetConfigurationSettingValue("TelemetrySummaryPrefix");
            _blobStorageManager = blobStorageClientFactory.CreateClient(telemetryStoreConnectionString,telemetryContainerName);
        }
예제 #28
0
        public static void UploadBytes(this IBlobStorageClient blobStorageClient, byte[] bytes, string blobName)
        {
            blobStorageClient.Require("blobStorageClient");
            bytes.Require("bytes");
            blobName.Require("blobName");

            if (bytes.Length == 0)
            {
                throw new ArgumentException("Byte array is empty.", "bytes");
            }

            blobStorageClient.UploadBlob(new MemoryStream(bytes), blobName);
        }
예제 #29
0
        /// <summary>
        /// Initializes a new instance of the AlertsRepository class.
        /// </summary>
        /// <param name="configProvider">
        /// The IConfigurationProvider implementation with which the new
        /// instance will be initialized.
        /// </param>
        public AlertsRepository(IConfigurationProvider configProvider, IBlobStorageClientFactory blobStorageClientFactory)
        {
            if (configProvider == null)
            {
                throw new ArgumentNullException("configProvider");
            }

            string alertsContainerConnectionString = configProvider.GetConfigurationSettingValue("device.StorageConnectionString");
            string alertsStoreContainerName        = configProvider.GetConfigurationSettingValue("AlertsStoreContainerName");

            this._blobStorageManager    = blobStorageClientFactory.CreateClient(alertsContainerConnectionString, alertsStoreContainerName);
            this.deviceAlertsDataPrefix = configProvider.GetConfigurationSettingValue("DeviceAlertsDataPrefix");
        }
 public StatusService(
     AppConfig config,
     IIotHubManagerClient iotHubManager,
     IBlobStorageClient blobStorageClient,
     IStorageAdapterClient storageAdapterClient)
     : base(config)
 {
     this.Dependencies = new Dictionary <string, IStatusOperation>
     {
         { "Storage Adapter", storageAdapterClient },
         { "IoTHub Manager", iotHubManager },
         { "Blob Storage", blobStorageClient },
     };
 }
예제 #31
0
        /// <summary>
        /// Initializes a new instance of the LocationJerkRepository class.
        /// </summary>
        /// <param name="configProvider">
        /// The IConfigurationProvider implementation with which to initialize
        /// the new instance.
        /// </param>
        /// <param name="blobStorageClientFactory">
        /// The IBlobStorageClientFactory implementation with which to initialize
        /// the new instance.
        /// </param>
        public LocationJerkRepository(IConfigurationProvider configProvider, IBlobStorageClientFactory blobStorageClientFactory)
        {
            if (configProvider == null)
            {
                throw new ArgumentNullException("configProvider");
            }

            string blobName         = configProvider.GetConfigurationSettingValue("LocationJerkBlobName");
            string connectionString = configProvider.GetConfigurationSettingValue("device.StorageConnectionString");
            string containerName    = configProvider.GetConfigurationSettingValue("LocationJerkContainerName");

            _blobName           = blobName;
            _blobStorageManager = blobStorageClientFactory.CreateClient(connectionString, containerName);
        }
        /// <summary>
        /// Initializes a new instance of the DeviceTelemetryRepository class.
        /// </summary>
        /// <param name="configProvider">
        /// The IConfigurationProvider implementation with which to initialize
        /// the new instance.
        /// </param>
        public DeviceTelemetryRepository(IConfigurationProvider configProvider, IBlobStorageClientFactory blobStorageClientFactory)
        {
            if (configProvider == null)
            {
                throw new ArgumentNullException("configProvider");
            }

            string telemetryContainerName = configProvider.GetConfigurationSettingValue("TelemetryStoreContainerName");

            _telemetryDataPrefix = configProvider.GetConfigurationSettingValue("TelemetryDataPrefix");
            string telemetryStoreConnectionString = configProvider.GetConfigurationSettingValue("device.StorageConnectionString");

            _telemetrySummaryPrefix = configProvider.GetConfigurationSettingValue("TelemetrySummaryPrefix");
            _blobStorageManager     = blobStorageClientFactory.CreateClient(telemetryStoreConnectionString, telemetryContainerName);
        }
예제 #33
0
        public LocationRulesRepository(IConfigurationProvider configurationProvider, IAzureTableStorageClientFactory tableStorageClientFactory, IBlobStorageClientFactory blobStorageClientFactory)
        {
            _storageAccountConnectionString      = configurationProvider.GetConfigurationSettingValue("device.StorageConnectionString");
            _locationRulesBlobStoreContainerName = configurationProvider.GetConfigurationSettingValue("LocationRulesStoreContainerName");
            _locationRulesNormalizedTableName    = configurationProvider.GetConfigurationSettingValue("LocationRulesTableName");
            _azureTableStorageClient             = tableStorageClientFactory.CreateClient(_storageAccountConnectionString, _locationRulesNormalizedTableName);
            _blobName          = configurationProvider.GetConfigurationSettingValue("AsaRefLocationRulesBlobName");
            _blobStorageClient = blobStorageClientFactory.CreateClient(_storageAccountConnectionString, _locationRulesBlobStoreContainerName);

            // note: InvariantCulture is read-only, so use en-US and hardcode all relevant aspects
            CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");

            _formatInfo = culture.DateTimeFormat;
            _formatInfo.ShortDatePattern = @"yyyy-MM-dd";
            _formatInfo.ShortTimePattern = @"HH-mm";
        }
 public BlobStorageClientFactory(IBlobStorageClient customClient)
 {
     _blobStorageClient = customClient;
 }
 public IBlobStorageClient CreateClient(string storageConnectionString, string containerName)
 {
     return _blobStorageClient ??
            (_blobStorageClient = new BlobStorageClient(storageConnectionString, containerName));
 }