diff --git a/Consumer/Consumer.csproj b/Consumer/Consumer.csproj index 27e76ea..16881b3 100644 --- a/Consumer/Consumer.csproj +++ b/Consumer/Consumer.csproj @@ -1,14 +1,14 @@  - netcoreapp2.1 - v2 + netcoreapp3.1 + v3 - - - - + + + + diff --git a/Consumer/EventHubs/Functions.cs b/Consumer/EventHubs/Functions.cs index ae075e4..1dde526 100644 --- a/Consumer/EventHubs/Functions.cs +++ b/Consumer/EventHubs/Functions.cs @@ -56,7 +56,7 @@ public static async System.Threading.Tasks.Task EventHubProcessorAsync( jsonMessage.Add(@"_elapsedTimeMs", elapsedTimeMs); - log.LogTrace($@"[{ehMessage.Properties[@"TestRunId"]}]: Message received at {timestamp}: {jsonMessage.ToString()}"); + log.LogTrace($@"[{ehMessage.Properties[@"TestRunId"]}]: Message received at {timestamp}: {jsonMessage}"); log.LogMetric("messageProcessTimeMs", elapsedTimeMs, diff --git a/Consumer/ServiceBus/Functions.cs b/Consumer/ServiceBus/Functions.cs index 9cbad93..ddb7e69 100644 --- a/Consumer/ServiceBus/Functions.cs +++ b/Consumer/ServiceBus/Functions.cs @@ -20,7 +20,7 @@ public static async Task ServiceBusQueueProcessorAsync( ILogger log) { var timestamp = DateTime.UtcNow; - log.LogTrace($@"[{sbMessage.UserProperties[@"TestRunId"]}]: Message received at {timestamp}: {JObject.FromObject(sbMessage).ToString()}"); + log.LogTrace($@"[{sbMessage.UserProperties[@"TestRunId"]}]: Message received at {timestamp}: {JObject.FromObject(sbMessage)}"); var enqueuedTime = sbMessage.ScheduledEnqueueTimeUtc; var elapsedTimeMs = (timestamp - enqueuedTime).TotalMilliseconds; diff --git a/Consumer/StorageQueues/Functions.cs b/Consumer/StorageQueues/Functions.cs index 8cb2b85..017bb9e 100644 --- a/Consumer/StorageQueues/Functions.cs +++ b/Consumer/StorageQueues/Functions.cs @@ -52,7 +52,7 @@ public static async System.Threading.Tasks.Task StorageQueueProcessorAsync( await collector.AddAsync(collectorItem.ToString()); jsonMessage.Add(@"_elapsedTimeMs", elapsedTimeMs); - log.LogTrace($@"[{jsonContent.Value(@"TestRunId")}]: Message received at {timestamp}: {jsonMessage.ToString()}"); + log.LogTrace($@"[{jsonContent.Value(@"TestRunId")}]: Message received at {timestamp}: {jsonMessage}"); log.LogMetric("messageProcessTimeMs", elapsedTimeMs, diff --git a/Producer/CosmosDb/Functions.cs b/Producer/CosmosDb/Functions.cs index 06bbae3..7e42ff5 100644 --- a/Producer/CosmosDb/Functions.cs +++ b/Producer/CosmosDb/Functions.cs @@ -1,11 +1,12 @@ using System; using System.IO; using System.Linq; -using System.Net.Http; using System.Reflection; using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.WebJobs; -using Microsoft.Azure.WebJobs.Host; +using Microsoft.Azure.WebJobs.Extensions.DurableTask; using Microsoft.Azure.WebJobs.Extensions.Http; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; @@ -15,12 +16,12 @@ namespace Producer.CosmosDb public static class Functions { [FunctionName(nameof(PostToCosmosDb))] - public static async Task PostToCosmosDb( - [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestMessage request, - [OrchestrationClient]DurableOrchestrationClient client, + public static async Task PostToCosmosDb( + [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest request, + [DurableClient] IDurableOrchestrationClient client, ILogger log) { - var inputObject = JObject.Parse(await request.Content.ReadAsStringAsync()); + var inputObject = JObject.Parse(await request.ReadAsStringAsync()); var numberOfMessages = inputObject.Value(@"NumberOfMessages"); var workTime = -1; @@ -31,7 +32,7 @@ public static async Task PostToCosmosDb( var testRunId = Guid.NewGuid().ToString(); var orchId = await client.StartNewAsync(nameof(GenerateMessagesForCosmosDb), - (numberOfMessages, testRunId, workTime)); + Tuple.Create(numberOfMessages, testRunId, workTime)); log.LogTrace($@"Kicked off {numberOfMessages} message creation..."); @@ -40,7 +41,7 @@ public static async Task PostToCosmosDb( [FunctionName(nameof(GenerateMessagesForCosmosDb))] public static async Task GenerateMessagesForCosmosDb( - [OrchestrationTrigger]DurableOrchestrationContext ctx, + [OrchestrationTrigger] IDurableOrchestrationContext ctx, ILogger log) { var req = ctx.GetInput<(int numOfMessages, string testRunId, int workTime)>(); @@ -50,12 +51,12 @@ public static async Task GenerateMessagesForCosmosDb( { try { - activities.Add(ctx.CallActivityAsync(nameof(PostMessageToCosmosDb), (Guid.NewGuid(), req.testRunId, req.workTime))); + activities.Add(ctx.CallActivityAsync(nameof(PostMessageToCosmosDb), (ctx.NewGuid(), req.testRunId, req.workTime))); } catch (Exception ex) { log.LogError(ex, @"An error occurred queuing message generation to Cosmos DB"); - return JObject.FromObject(new { Error = $@"An error occurred executing orchestration {ctx.InstanceId}: {ex.ToString()}" }); + return JObject.FromObject(new { Error = $@"An error occurred executing orchestration {ctx.InstanceId}: {ex}" }); } } @@ -67,14 +68,12 @@ public static async Task GenerateMessagesForCosmosDb( private const int MAX_RETRY_ATTEMPTS = 10; private static readonly Lazy _messageContent = new Lazy(() => { - using (var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($@"Producer.messagecontent.txt"))) - { - return sr.ReadToEnd(); - } + using var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($@"Producer.messagecontent.txt")); + return sr.ReadToEnd(); }); [FunctionName(nameof(PostMessageToCosmosDb))] - public static async Task PostMessageToCosmosDb([ActivityTrigger]DurableActivityContext ctx, + public static async Task PostMessageToCosmosDb([ActivityTrigger] IDurableActivityContext ctx, [CosmosDB(databaseName: "%CosmosDbDatabaseName%", collectionName: "%CosmosDbCollectionName%", ConnectionStringSetting = @"CosmosDbConnection", @@ -90,7 +89,7 @@ public static async Task PostMessageToCosmosDb([ActivityTrigger]DurableAct { Content = _messageContent.Value, EnqueueTimeUtc = DateTime.UtcNow, - id = msgDetails.id, // <- cosmos id field? + msgDetails.id, // <- cosmos id field? TestRunId = msgDetails.runId // <- cosmos partition field? }); diff --git a/Producer/EventGrid/Functions.cs b/Producer/EventGrid/Functions.cs index 5b2d197..617c912 100644 --- a/Producer/EventGrid/Functions.cs +++ b/Producer/EventGrid/Functions.cs @@ -1,11 +1,13 @@ using System; using System.IO; using System.Linq; -using System.Net.Http; using System.Reflection; using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.EventGrid.Models; using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.DurableTask; using Microsoft.Azure.WebJobs.Extensions.EventGrid; using Microsoft.Azure.WebJobs.Extensions.Http; using Microsoft.Extensions.Logging; @@ -16,12 +18,12 @@ namespace Producer.EventGrid public class Functions { [FunctionName(nameof(PostToEventGrid))] - public async Task PostToEventGrid( - [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestMessage request, - [OrchestrationClient] DurableOrchestrationClient client, + public async Task PostToEventGrid( + [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest request, + [DurableClient] IDurableOrchestrationClient client, ILogger log) { - var inputObject = JObject.Parse(await request.Content.ReadAsStringAsync()); + var inputObject = JObject.Parse(await request.ReadAsStringAsync()); var numberOfMessages = inputObject.Value(@"NumberOfMessages"); var workTime = -1; @@ -41,7 +43,7 @@ public async Task PostToEventGrid( [FunctionName(nameof(GenerateMessagesForEventGrid))] public async Task GenerateMessagesForEventGrid( - [OrchestrationTrigger] DurableOrchestrationContext ctx, + [OrchestrationTrigger] IDurableOrchestrationContext ctx, ILogger log) { var req = ctx.GetInput<(int numOfMessages, string testRunId, int workTime)>(); @@ -56,7 +58,7 @@ public async Task GenerateMessagesForEventGrid( catch (Exception ex) { log.LogError(ex, @"An error occurred queuing message generation to Storage Queue"); - return JObject.FromObject(new { Error = $@"An error occurred executing orchestration {ctx.InstanceId}: {ex.ToString()}" }); + return JObject.FromObject(new { Error = $@"An error occurred executing orchestration {ctx.InstanceId}: {ex}" }); } } @@ -69,14 +71,12 @@ public async Task GenerateMessagesForEventGrid( private const int MAX_RETRY_ATTEMPTS = 10; private static readonly Lazy _messageContent = new Lazy(() => { - using (var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($@"Producer.messagecontent.txt"))) - { - return sr.ReadToEnd(); - } + using var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($@"Producer.messagecontent.txt")); + return sr.ReadToEnd(); }); [FunctionName(nameof(PostMessageToEventGrid))] - public async Task PostMessageToEventGrid([ActivityTrigger] DurableActivityContext ctx, + public async Task PostMessageToEventGrid([ActivityTrigger] IDurableActivityContext ctx, [EventGrid(TopicEndpointUri = "EventGridTopicEndpoint", TopicKeySetting = "EventGridTopicKey")] IAsyncCollector gridMessages, ILogger log) { diff --git a/Producer/EventHubs/Functions.cs b/Producer/EventHubs/Functions.cs index 53ff939..25fcd79 100644 --- a/Producer/EventHubs/Functions.cs +++ b/Producer/EventHubs/Functions.cs @@ -2,12 +2,14 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Net.Http; using System.Reflection; using System.Text; using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.EventHubs; using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.DurableTask; using Microsoft.Azure.WebJobs.Extensions.Http; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; @@ -17,12 +19,12 @@ namespace Producer.EventHubs public static class Functions { [FunctionName(nameof(PostToEventHub))] - public static async Task PostToEventHub( - [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestMessage request, - [OrchestrationClient]DurableOrchestrationClient client, + public static async Task PostToEventHub( + [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest request, + [DurableClient] IDurableOrchestrationClient client, ILogger log) { - var inputObject = JObject.Parse(await request.Content.ReadAsStringAsync()); + var inputObject = JObject.Parse(await request.ReadAsStringAsync()); var numberOfMessagesPerPartition = inputObject.Value(@"NumberOfMessagesPerPartition"); var numberOfPartitions = Convert.ToInt32(Environment.GetEnvironmentVariable("EventHubPartitions")); @@ -55,7 +57,7 @@ public static async Task PostToEventHub( [FunctionName(nameof(GenerateMessagesForEventHub))] public static async Task GenerateMessagesForEventHub( - [OrchestrationTrigger]DurableOrchestrationContext ctx, + [OrchestrationTrigger] IDurableOrchestrationContext ctx, ILogger log) { var req = ctx.GetInput(); @@ -63,7 +65,7 @@ public static async Task GenerateMessagesForEventHub( var messages = Enumerable.Range(1, req.NumberOfMessagesPerPartition) .Select(m => { - var enqueueTime = DateTime.UtcNow; + var enqueueTime = ctx.CurrentUtcDateTime; return new MessagesSendRequest { MessageId = m, @@ -82,22 +84,20 @@ public static async Task GenerateMessagesForEventHub( catch (Exception ex) { log.LogError(ex, @"An error occurred queuing message generation to Event Hub"); - return JObject.FromObject(new { Error = $@"An error occurred executing orchestration {ctx.InstanceId}: {ex.ToString()}" }); + return JObject.FromObject(new { Error = $@"An error occurred executing orchestration {ctx.InstanceId}: {ex}" }); } } private const int MAX_RETRY_ATTEMPTS = 10; private static readonly Lazy _messageContent = new Lazy(() => { - using (var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($@"Producer.messagecontent.txt"))) - { - return sr.ReadToEnd(); - } + using var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($@"Producer.messagecontent.txt")); + return sr.ReadToEnd(); }); [FunctionName(nameof(PostMessagesToEventHub))] - public static async Task PostMessagesToEventHub([ActivityTrigger]DurableActivityContext ctx, - [EventHub("%EventHubName%", Connection = @"EventHubConnection")]IAsyncCollector queueMessages, + public static async Task PostMessagesToEventHub([ActivityTrigger] IDurableActivityContext ctx, + [EventHub("%EventHubName%", Connection = @"EventHubConnection")] IAsyncCollector queueMessages, ILogger log) { var messages = ctx.GetInput>(); diff --git a/Producer/EventHubsKafka/Functions.cs b/Producer/EventHubsKafka/Functions.cs index c41f393..60404d5 100644 --- a/Producer/EventHubsKafka/Functions.cs +++ b/Producer/EventHubsKafka/Functions.cs @@ -2,28 +2,29 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Net.Http; using System.Reflection; using System.Threading.Tasks; -using System.Configuration; +using Confluent.Kafka; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.DurableTask; using Microsoft.Azure.WebJobs.Extensions.Http; using Microsoft.Extensions.Logging; -using Newtonsoft.Json.Linq; -using Confluent.Kafka; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace Producer.EventHubsKafka { public static class Functions { [FunctionName(nameof(PostToEventHubKafka))] - public static async Task PostToEventHubKafka( - [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestMessage request, - [OrchestrationClient]DurableOrchestrationClient client, + public static async Task PostToEventHubKafka( + [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest request, + [DurableClient] IDurableOrchestrationClient client, ILogger log) { - var inputObject = JObject.Parse(await request.Content.ReadAsStringAsync()); + var inputObject = JObject.Parse(await request.ReadAsStringAsync()); var numberOfMessagesPerPartition = inputObject.Value(@"NumberOfMessagesPerPartition"); var numberOfPartitions = Convert.ToInt32(Environment.GetEnvironmentVariable("EventHubKafkaPartitions")); @@ -55,7 +56,7 @@ public static async Task PostToEventHubKafka( [FunctionName(nameof(GenerateMessagesForEventHubKafka))] public static async Task GenerateMessagesForEventHubKafka( - [OrchestrationTrigger]DurableOrchestrationContext ctx, + [OrchestrationTrigger] IDurableOrchestrationContext ctx, ILogger log) { var req = ctx.GetInput(); @@ -63,7 +64,7 @@ public static async Task GenerateMessagesForEventHubKafka( var messages = Enumerable.Range(1, req.NumberOfMessagesPerPartition) .Select(m => { - var enqueueTime = DateTime.UtcNow; + var enqueueTime = ctx.CurrentUtcDateTime; return new MessagesSendRequest { MessageId = m, @@ -82,21 +83,19 @@ public static async Task GenerateMessagesForEventHubKafka( catch (Exception ex) { log.LogError(ex, @"An error occurred queuing message generation to Event Hub"); - return JObject.FromObject(new { Error = $@"An error occurred executing orchestration {ctx.InstanceId}: {ex.ToString()}" }); + return JObject.FromObject(new { Error = $@"An error occurred executing orchestration {ctx.InstanceId}: {ex}" }); } } private const int MAX_RETRY_ATTEMPTS = 10; private static readonly Lazy _messageContent = new Lazy(() => { - using (var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($@"Producer.messagecontent.txt"))) - { - return sr.ReadToEnd(); - } + using var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($@"Producer.messagecontent.txt")); + return sr.ReadToEnd(); }); [FunctionName(nameof(PostMessagesToEventHubKafka))] - public static async Task PostMessagesToEventHubKafka([ActivityTrigger]DurableActivityContext ctx, + public static async Task PostMessagesToEventHubKafka([ActivityTrigger] IDurableActivityContext ctx, ILogger log) { string brokerList = Environment.GetEnvironmentVariable("EventHubKafkaFQDN"); diff --git a/Producer/Producer.csproj b/Producer/Producer.csproj index ce45386..2d0202e 100644 --- a/Producer/Producer.csproj +++ b/Producer/Producer.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 - v2 + netcoreapp3.1 + v3 @@ -16,16 +16,16 @@ - - - + + + - + - - - - + + + + diff --git a/Producer/ServiceBus/Functions.cs b/Producer/ServiceBus/Functions.cs index e01c2cb..6019979 100644 --- a/Producer/ServiceBus/Functions.cs +++ b/Producer/ServiceBus/Functions.cs @@ -2,12 +2,14 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Net.Http; using System.Reflection; using System.Text; using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.ServiceBus; using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.DurableTask; using Microsoft.Azure.WebJobs.Extensions.Http; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; @@ -17,12 +19,12 @@ namespace Producer.ServiceBus public static class Functions { [FunctionName(nameof(PostToServiceBusQueue))] - public static async Task PostToServiceBusQueue( - [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestMessage request, - [OrchestrationClient]DurableOrchestrationClient client, + public static async Task PostToServiceBusQueue( + [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest request, + [DurableClient] IDurableOrchestrationClient client, ILogger log) { - var inputObject = JObject.Parse(await request.Content.ReadAsStringAsync()); + var inputObject = JObject.Parse(await request.ReadAsStringAsync()); var numberOfMessagesPerSession = inputObject.Value(@"NumberOfMessagesPerSession"); var numberOfSessions = inputObject.Value(@"NumberOfSessions"); @@ -56,7 +58,7 @@ public static async Task PostToServiceBusQueue( [FunctionName(nameof(GenerateMessagesForServiceBusSession))] public static async Task GenerateMessagesForServiceBusSession( - [OrchestrationTrigger]DurableOrchestrationContext ctx, + [OrchestrationTrigger] IDurableOrchestrationContext ctx, ILogger log) { var req = ctx.GetInput(); @@ -68,7 +70,7 @@ public static async Task GenerateMessagesForServiceBusSession( { SessionId = req.SessionId, MessageId = m, - EnqueueTimeUtc = DateTime.UtcNow, + EnqueueTimeUtc = ctx.CurrentUtcDateTime, TestRunId = req.TestRunId, ConsumerWorkTime = req.ConsumerWorkTime, }; @@ -83,23 +85,21 @@ public static async Task GenerateMessagesForServiceBusSession( catch (Exception ex) { log.LogError(ex, @"An error occurred queuing message generation to SB queue"); - return JObject.FromObject(new { Error = $@"An error occurred executing orchestration {ctx.InstanceId}: {ex.ToString()}" }); + return JObject.FromObject(new { Error = $@"An error occurred executing orchestration {ctx.InstanceId}: {ex}" }); } } private static readonly Lazy _messageContent = new Lazy(() => { - using (var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($@"Producer.messagecontent.txt"))) - { - return Encoding.Default.GetBytes(sr.ReadToEnd()); - } + using var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($@"Producer.messagecontent.txt")); + return Encoding.Default.GetBytes(sr.ReadToEnd()); }); private const int MAX_RETRY_ATTEMPTS = 10; [FunctionName(nameof(PostMessagesToServiceBusQueue))] - public static async Task PostMessagesToServiceBusQueue([ActivityTrigger]DurableActivityContext ctx, - [ServiceBus("%ServiceBusQueueName%", Connection = @"ServiceBusConnection")]IAsyncCollector queueMessages, + public static async Task PostMessagesToServiceBusQueue([ActivityTrigger] IDurableActivityContext ctx, + [ServiceBus("%ServiceBusQueueName%", Connection = @"ServiceBusConnection")] IAsyncCollector queueMessages, ILogger log) { var messages = ctx.GetInput>(); diff --git a/Producer/StorageQueues/Functions.cs b/Producer/StorageQueues/Functions.cs index 5526036..24767fa 100644 --- a/Producer/StorageQueues/Functions.cs +++ b/Producer/StorageQueues/Functions.cs @@ -4,7 +4,10 @@ using System.Net.Http; using System.Reflection; using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.WebJobs; +using Microsoft.Azure.WebJobs.Extensions.DurableTask; using Microsoft.Azure.WebJobs.Extensions.Http; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; @@ -14,12 +17,12 @@ namespace Producer.StorageQueues public static class Functions { [FunctionName(nameof(PostToStorageQueue))] - public static async Task PostToStorageQueue( - [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestMessage request, - [OrchestrationClient]DurableOrchestrationClient client, + public static async Task PostToStorageQueue( + [HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest request, + [DurableClient] IDurableOrchestrationClient client, ILogger log) { - var inputObject = JObject.Parse(await request.Content.ReadAsStringAsync()); + var inputObject = JObject.Parse(await request.ReadAsStringAsync()); var numberOfMessages = inputObject.Value(@"NumberOfMessages"); var workTime = -1; @@ -30,7 +33,7 @@ public static async Task PostToStorageQueue( var testRunId = Guid.NewGuid().ToString(); var orchId = await client.StartNewAsync(nameof(GenerateMessagesForStorageQueue), - (numberOfMessages, testRunId, workTime)); + Tuple.Create(numberOfMessages, testRunId, workTime)); log.LogTrace($@"Kicked off {numberOfMessages} message creation..."); @@ -39,7 +42,7 @@ public static async Task PostToStorageQueue( [FunctionName(nameof(GenerateMessagesForStorageQueue))] public static async Task GenerateMessagesForStorageQueue( - [OrchestrationTrigger]DurableOrchestrationContext ctx, + [OrchestrationTrigger] IDurableOrchestrationContext ctx, ILogger log) { var req = ctx.GetInput<(int numOfMessages, string testRunId, int workTime)>(); @@ -54,7 +57,7 @@ public static async Task GenerateMessagesForStorageQueue( catch (Exception ex) { log.LogError(ex, @"An error occurred queuing message generation to Storage Queue"); - return JObject.FromObject(new { Error = $@"An error occurred executing orchestration {ctx.InstanceId}: {ex.ToString()}" }); + return JObject.FromObject(new { Error = $@"An error occurred executing orchestration {ctx.InstanceId}: {ex}" }); } } @@ -66,15 +69,13 @@ public static async Task GenerateMessagesForStorageQueue( private const int MAX_RETRY_ATTEMPTS = 10; private static readonly Lazy _messageContent = new Lazy(() => { - using (var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($@"Producer.messagecontent.txt"))) - { - return sr.ReadToEnd(); - } + using var sr = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream($@"Producer.messagecontent.txt")); + return sr.ReadToEnd(); }); [FunctionName(nameof(PostMessageToStorageQueue))] - public static async Task PostMessageToStorageQueue([ActivityTrigger]DurableActivityContext ctx, - [Queue("%StorageQueueName%", Connection = @"StorageQueueConnection")]IAsyncCollector queueMessages, + public static async Task PostMessageToStorageQueue([ActivityTrigger] IDurableActivityContext ctx, + [Queue("%StorageQueueName%", Connection = @"StorageQueueConnection")] IAsyncCollector queueMessages, ILogger log) { var msgDetails = ctx.GetInput<(int id, string runId, int workTime)>();