From c89c75a623e5ccfbd758855dec39ed673c1cbe7b Mon Sep 17 00:00:00 2001 From: Madalyn Redding Date: Mon, 18 Nov 2024 12:15:54 -0500 Subject: [PATCH] net8.0 target follow up --- .../src/AuthenticationEventBinding.cs | 5 +++++ .../src/AuthenticationEventConfigProvider.cs | 5 +++++ .../src/Listeners/BlobQueueTriggerExecutor.cs | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/sdk/entra/Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents/src/AuthenticationEventBinding.cs b/sdk/entra/Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents/src/AuthenticationEventBinding.cs index da881aa8c64be..afbb9376a07f3 100644 --- a/sdk/entra/Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents/src/AuthenticationEventBinding.cs +++ b/sdk/entra/Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents/src/AuthenticationEventBinding.cs @@ -86,8 +86,13 @@ private static IReadOnlyDictionary GetBindingDataContract(Paramete public async Task BindAsync(object value, ValueBindingContext context) { var request = (HttpRequestMessage)value; +#if NET8_0_OR_GREATER + HttpRequestOptionsKey httpRequestOptionsKey = new(WebJobsAuthenticationEventResponseHandler.EventResponseProperty); + request.Options.TryGetValue(httpRequestOptionsKey, out WebJobsAuthenticationEventResponseHandler eventResponseHandler); +#else WebJobsAuthenticationEventResponseHandler eventResponseHandler = (WebJobsAuthenticationEventResponseHandler)request.Properties[WebJobsAuthenticationEventResponseHandler.EventResponseProperty]; +#endif try { if (request == null) diff --git a/sdk/entra/Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents/src/AuthenticationEventConfigProvider.cs b/sdk/entra/Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents/src/AuthenticationEventConfigProvider.cs index bbd31846af81c..b9a92cd1cb3d4 100644 --- a/sdk/entra/Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents/src/AuthenticationEventConfigProvider.cs +++ b/sdk/entra/Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents/src/AuthenticationEventConfigProvider.cs @@ -109,7 +109,12 @@ public async Task ConvertAsync(HttpRequestMessage input, Ca //We create an event response handler and attach it to the income HTTP message, then on the trigger we set the function response //in the event response handler and after the executor calls the functions we have reference to the function response. WebJobsAuthenticationEventResponseHandler eventsResponseHandler = new WebJobsAuthenticationEventResponseHandler(); +#if NET8_0_OR_GREATER + HttpRequestOptionsKey httpRequestOptionsKey = new(WebJobsAuthenticationEventResponseHandler.EventResponseProperty); + input.Options.Set(httpRequestOptionsKey, eventsResponseHandler); +#else input.Properties.Add(WebJobsAuthenticationEventResponseHandler.EventResponseProperty, eventsResponseHandler); +#endif TriggeredFunctionData triggerData = new TriggeredFunctionData() { diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/src/Listeners/BlobQueueTriggerExecutor.cs b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/src/Listeners/BlobQueueTriggerExecutor.cs index 1e62392c24a18..4a3c33391493f 100644 --- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/src/Listeners/BlobQueueTriggerExecutor.cs +++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/src/Listeners/BlobQueueTriggerExecutor.cs @@ -115,12 +115,16 @@ public async Task ExecuteAsync(QueueMessage value, CancellationT // Include the queue details here. IDictionary details = PopulateTriggerDetails(value); +#pragma warning disable CS8073 // The result of the expression is always true in net8.0, but not this is not true in netstandard2.0 if (blobProperties.CreatedOn != null) +#pragma warning restore CS8073 { details[BlobCreatedKey] = blobProperties.CreatedOn.ToString(Constants.DateTimeFormatString, CultureInfo.InvariantCulture); } +#pragma warning disable CS8073 // The result of the expression is always true in net8.0, but not this is not true in netstandard2.0 if (blobProperties.LastModified != null) +#pragma warning restore CS8073 { details[BlobLastModifiedKey] = blobProperties.LastModified.ToString(Constants.DateTimeFormatString, CultureInfo.InvariantCulture); }