示例#1
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation("Mail Background Service is starting.");
            var configuration = _environment.GetAppConfiguration();
            var apiKey        = configuration["App:SendGrid:ApiKey"];

            _sendGridClient = new SendGridClient(apiKey);
            // Connection String for the namespace can be obtained from the Azure portal under the
            // 'Shared Access policies' section.
            _queueClient = new QueueClient(configuration["App:ServiceBus:ConnectionString"], configuration["App:ServiceBus:QueueName"]);
            // Register QueueClient's MessageHandler and receive messages in a loop
            RegisterMessageConsumer();

            return(Task.CompletedTask);
        }
示例#2
0
 public Startup(IHostingEnvironment env)
 {
     _appConfiguration = env.GetAppConfiguration();
 }