public static async Task <string> Run([ActivityTrigger] ServiceBusJobProperties sbJobProperties, TraceWriter log)
        {
            QueueClient queueClient = new QueueClient(sbJobProperties.ConnectionString, sbJobProperties.Queue);

            int secondsPerBatch           = Convert.ToInt16(Environment.GetEnvironmentVariable("secondsPerBatch"));
            int messagesInBatch           = sbJobProperties.Frequency * secondsPerBatch;
            IEnumerable <string> messages = Messages.CreateMessages(messagesInBatch, sbJobProperties.MessageScheme);

            try
            {
                var sbMessages = (List <Message>)messages.Select(m => new Message()
                {
                    Body        = Encoding.UTF8.GetBytes(m),
                    ContentType = "text/plain"
                }
                                                                 );

                await queueClient.SendAsync(sbMessages);

                await queueClient.CloseAsync();
            }
            catch (Exception exception)
            {
                log.Info($"Exception: {exception.Message}");
            }

            log.Info($"sent batch of {messages.Count()} messages");
            return($"finished sending {messages.Count()} to {sbJobProperties.Queue}!");
        }
        public static async Task <string> Run([ActivityTrigger] ServiceBusJobProperties sbJobProperties, TraceWriter log)
        {
            QueueClient queueClient = new QueueClient(sbJobProperties.ConnectionString, sbJobProperties.Queue);

            int numOfMessages = sbJobProperties.Frequency * 60 * sbJobProperties.Duration;

            string[] messages = (string[])Messages.CreateMessages(numOfMessages, sbJobProperties.MessageScheme);
            for (var i = 0; i < numOfMessages; i++)
            {
                try
                {
                    var message = messages[i];
                    log.Info($"Sending message: {message}");
                    var body = Encoding.UTF8.GetBytes(message);
                    await queueClient.SendAsync(new Message { Body = body, ContentType = "text/plain" });
                }
                catch (Exception exception)
                {
                    log.Info($"Exception: {exception.Message}");
                }
                await Task.Delay(1000 / sbJobProperties.Frequency);
            }
            await queueClient.CloseAsync();

            log.Info($"finished.");
            return($"finished sending {numOfMessages} to {sbJobProperties.Queue}!");
        }