From 40535e0beaae64fbf536fde04b5ab7c88b22c3f2 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Fri, 23 Jun 2023 12:10:49 +1000 Subject: [PATCH 1/4] Updating to .NET 7 --- Api/Api.csproj | 2 +- Client/Client.csproj | 6 +++--- Data/Data.csproj | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Api/Api.csproj b/Api/Api.csproj index b0e32f0..44f6afb 100644 --- a/Api/Api.csproj +++ b/Api/Api.csproj @@ -1,6 +1,6 @@ - net6.0 + net7.0 v4 diff --git a/Client/Client.csproj b/Client/Client.csproj index 7542c27..738f744 100644 --- a/Client/Client.csproj +++ b/Client/Client.csproj @@ -1,14 +1,14 @@ - net6.0 + net7.0 disable enable - - + + diff --git a/Data/Data.csproj b/Data/Data.csproj index dbc1517..8268829 100644 --- a/Data/Data.csproj +++ b/Data/Data.csproj @@ -1,7 +1,7 @@ - net6.0 + net7.0 From ae0d40bfc26ca51dc98439e64a169e04a4426b59 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Fri, 23 Jun 2023 12:30:58 +1000 Subject: [PATCH 2/4] Porting to dotnet-isolated for Functions --- Api/Api.csproj | 7 +++++-- Api/ProductsDelete.cs | 5 ++--- Api/ProductsPost.cs | 5 ++--- Api/ProductsPut.cs | 11 +++++------ Api/Program.cs | 24 ++++++++++++++++++++++++ Api/Startup.cs | 14 -------------- Api/local.settings.example.json | 8 ++++---- 7 files changed, 42 insertions(+), 32 deletions(-) create mode 100644 Api/Program.cs delete mode 100644 Api/Startup.cs diff --git a/Api/Api.csproj b/Api/Api.csproj index 44f6afb..8dfc3ef 100644 --- a/Api/Api.csproj +++ b/Api/Api.csproj @@ -2,10 +2,13 @@ net7.0 v4 + Exe - - + + + + diff --git a/Api/ProductsDelete.cs b/Api/ProductsDelete.cs index 1ded437..0ab6963 100644 --- a/Api/ProductsDelete.cs +++ b/Api/ProductsDelete.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Azure.WebJobs; -using Microsoft.Azure.WebJobs.Extensions.Http; +using Microsoft.Azure.Functions.Worker; using Microsoft.Extensions.Logging; using System.Threading.Tasks; @@ -16,7 +15,7 @@ public ProductsDelete(IProductData productData) this.productData = productData; } - [FunctionName("ProductsDelete")] + [Function("ProductsDelete")] public async Task Run( [HttpTrigger(AuthorizationLevel.Anonymous, "delete", Route = "products/{productId:int}")] HttpRequest req, int productId, diff --git a/Api/ProductsPost.cs b/Api/ProductsPost.cs index f35982b..e402ac3 100644 --- a/Api/ProductsPost.cs +++ b/Api/ProductsPost.cs @@ -1,12 +1,11 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Azure.WebJobs; -using Microsoft.Azure.WebJobs.Extensions.Http; using Microsoft.Extensions.Logging; using System.IO; using System.Text.Json; using System.Threading.Tasks; using Data; +using Microsoft.Azure.Functions.Worker; namespace Api; @@ -19,7 +18,7 @@ public ProductsPost(IProductData productData) this.productData = productData; } - [FunctionName("ProductsPost")] + [Function("ProductsPost")] public async Task Run( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "products")] HttpRequest req, ILogger log) diff --git a/Api/ProductsPut.cs b/Api/ProductsPut.cs index a2c285a..f79176d 100644 --- a/Api/ProductsPut.cs +++ b/Api/ProductsPut.cs @@ -1,12 +1,11 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Azure.WebJobs; -using Microsoft.Azure.WebJobs.Extensions.Http; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using System.IO; using System.Text.Json; using System.Threading.Tasks; using Data; +using Microsoft.Azure.Functions.Worker; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; namespace Api; @@ -19,7 +18,7 @@ public ProductsPut(IProductData productData) this.productData = productData; } - [FunctionName("ProductsPut")] + [Function("ProductsPut")] public async Task Run( [HttpTrigger(AuthorizationLevel.Anonymous, "put", Route = "products")] HttpRequest req, ILogger log) diff --git a/Api/Program.cs b/Api/Program.cs new file mode 100644 index 0000000..330fed4 --- /dev/null +++ b/Api/Program.cs @@ -0,0 +1,24 @@ +using Microsoft.Azure.Functions.Worker; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Api; + +public class Program +{ + public static void Main() + { + var host = new HostBuilder() + .ConfigureFunctionsWorkerDefaults(workerApplication => + { + workerApplication.UseAspNetCoreIntegration(); + }) + .ConfigureServices(services => + { + services.AddSingleton(); + }) + .Build(); + + host.Run(); + } +} diff --git a/Api/Startup.cs b/Api/Startup.cs deleted file mode 100644 index 6117555..0000000 --- a/Api/Startup.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.Azure.Functions.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection; - -[assembly: FunctionsStartup(typeof(Api.Startup))] - -namespace Api; - -public class Startup : FunctionsStartup -{ - public override void Configure(IFunctionsHostBuilder builder) - { - builder.Services.AddSingleton(); - } -} diff --git a/Api/local.settings.example.json b/Api/local.settings.example.json index b5dcd00..20f22b7 100644 --- a/Api/local.settings.example.json +++ b/Api/local.settings.example.json @@ -1,9 +1,9 @@ { "IsEncrypted": false, - "Values": { - "AzureWebJobsStorage": "", - "FUNCTIONS_WORKER_RUNTIME": "dotnet" - }, + "Values": { + "AzureWebJobsStorage": "", + "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" + }, "Host": { "LocalHttpPort": 7071, "CORS": "*", From 087d28ed25df43adec817e8a8c5a81209fb6b7a4 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Fri, 23 Jun 2023 14:43:43 +1000 Subject: [PATCH 3/4] Update Client/Client.csproj Co-authored-by: Jon Galloway --- Client/Client.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/Client.csproj b/Client/Client.csproj index 738f744..b7d7ecc 100644 --- a/Client/Client.csproj +++ b/Client/Client.csproj @@ -7,8 +7,8 @@ - - + + From f58861c68ee8d7f17b663aca04146b1c6cfffd2e Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Fri, 23 Jun 2023 15:14:16 +1000 Subject: [PATCH 4/4] Using the aspnet integration for better types and updating dependencies --- Api/Api.csproj | 4 ++-- Api/Program.cs | 32 +++++++++++++------------------- Api/local.settings.example.json | 3 ++- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/Api/Api.csproj b/Api/Api.csproj index 8dfc3ef..9f6fbcf 100644 --- a/Api/Api.csproj +++ b/Api/Api.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/Api/Program.cs b/Api/Program.cs index 330fed4..2f7d78b 100644 --- a/Api/Program.cs +++ b/Api/Program.cs @@ -1,24 +1,18 @@ -using Microsoft.Azure.Functions.Worker; +using Api; +using Microsoft.Azure.Functions.Worker; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -namespace Api; - -public class Program -{ - public static void Main() +var host = new HostBuilder() + .ConfigureFunctionsWorkerDefaults(workerApplication => + { + workerApplication.UseAspNetCoreIntegration(); + }) + .ConfigureAspNetCoreIntegration() + .ConfigureServices(services => { - var host = new HostBuilder() - .ConfigureFunctionsWorkerDefaults(workerApplication => - { - workerApplication.UseAspNetCoreIntegration(); - }) - .ConfigureServices(services => - { - services.AddSingleton(); - }) - .Build(); + services.AddSingleton(); + }) + .Build(); - host.Run(); - } -} +host.Run(); diff --git a/Api/local.settings.example.json b/Api/local.settings.example.json index 20f22b7..ca237cf 100644 --- a/Api/local.settings.example.json +++ b/Api/local.settings.example.json @@ -2,7 +2,8 @@ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "", - "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" + "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated", + "AzureWebJobsFeatureFlags": "EnableHttpProxying" }, "Host": { "LocalHttpPort": 7071,