Ejemplo n.º 1
0
        /// <summary>
        /// Try to send message through bot.
        /// </summary>
        /// <param name="queueName">Service Bus Queue name</param>
        /// <param name="message">Service Bus Queue message</param>
        /// <returns></returns>
        private async Task SendMessage(string queueName, ServiceBusMessage message)
        {
            try
            {
                var queueClient = new QueueClient(_configuration.ConnectionStrings.ServiceBus, queueName);

                // Create a new message to send to the queue.
                var serviceBusMessage = new Message(Encoding.UTF8.GetBytes(message.ToJson()));

                // Send the message to the queue.
                await queueClient.SendAsync(serviceBusMessage);

                await queueClient.CloseAsync();
            }
            catch (Exception e)
            {
                _telemetryClient.TrackException(e);
            }
        }