Example #1
0
 public WorkerService(ILogger <WorkerService> logger,
                      IOptions <AzureCognitiveServicesConfig> configCognitiveServices,
                      IOptions <AzureStorageConfig> configAzureStorage)
 {
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
     _configCognitiveServices = configCognitiveServices.Value;
     _configAzureStorage      = configAzureStorage.Value;
 }
Example #2
0
        private static ITextAnalyticsClient GetTextAnalyticsClient(AzureCognitiveServicesConfig config)
        {
            var textAnalyticsClient = new TextAnalyticsClient(new ApiKeyServiceClientCredentials(config.ApiKey));

            textAnalyticsClient.BaseUri = new Uri(config.EndpointUrl);

            return(textAnalyticsClient);
        }
Example #3
0
        public FormRecognizerService(IDistributedCache distributedCache, IOptions <AzureCognitiveServicesConfig> config, ILogger <FormRecognizerService> logger)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            _distributedCache = distributedCache ?? throw new ArgumentNullException(nameof(distributedCache));
            _logger           = logger ?? throw new ArgumentNullException(nameof(logger));

            _config = config.Value;

            _client = new FormRecognizerClient(new Uri(_config.Endpoint), new AzureKeyCredential(_config.SubscriptionKey));
        }
        public CardIdRecognizerService(IOptions <AzureCognitiveServicesConfig> config, ILogger <CardIdRecognizerService> logger)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _config = config.Value;

            _httpClient = new HttpClient
            {
                BaseAddress = new Uri(_config.Endpoint)
            };

            // Request headers.
            _httpClient.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", _config.SubscriptionKey);
        }