Skip to content

Commit

Permalink
Migrate sample to .NET 8 (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasgauvin authored Dec 5, 2023
1 parent c036097 commit 83d3458
Show file tree
Hide file tree
Showing 29 changed files with 308 additions and 184 deletions.
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"ms-azuretools.vscode-azurefunctions",
"ms-dotnettools.csharp"
]
}
}
50 changes: 25 additions & 25 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch and Debug Standalone Blazor WebAssembly App",
"type": "blazorwasm",
"request": "launch",
"cwd": "${workspaceFolder}/Client"
},
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
],
"compounds": [
{
"name": "Client/Server",
"configurations": [
"Attach to .NET Functions",
"Launch and Debug Standalone Blazor WebAssembly App"
]
}
]
}
"version": "0.2.0",
"configurations": [
{
"name": "Launch and Debug Standalone Blazor WebAssembly App",
"type": "blazorwasm",
"request": "launch",
"cwd": "${workspaceFolder}/Client"
},
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
],
"compounds": [
{
"name": "Client/Server",
"configurations": [
"Attach to .NET Functions",
"Launch and Debug Standalone Blazor WebAssembly App"
]
}
]
}
10 changes: 5 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"azureFunctions.deploySubpath": "Api/bin/Release/net6.0/publish",
"azureFunctions.projectLanguage": "C#",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.preDeployTask": "publish"
"azureFunctions.deploySubpath": "Api/bin/Release/net8.0/publish",
"azureFunctions.projectLanguage": "C#",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.preDeployTask": "publish (functions)"
}
18 changes: 9 additions & 9 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "2.0.0",
"tasks": [
{
"label": "clean",
"label": "clean (functions)",
"command": "dotnet",
"args": [
"clean",
Expand All @@ -16,15 +16,15 @@
}
},
{
"label": "build",
"label": "build (functions)",
"command": "dotnet",
"args": [
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean",
"dependsOn": "clean (functions)",
"group": {
"kind": "build",
"isDefault": true
Expand All @@ -35,7 +35,7 @@
}
},
{
"label": "clean release",
"label": "clean release (functions)",
"command": "dotnet",
"args": [
"clean",
Expand All @@ -51,7 +51,7 @@
}
},
{
"label": "publish",
"label": "publish (functions)",
"command": "dotnet",
"args": [
"publish",
Expand All @@ -61,21 +61,21 @@
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean release",
"dependsOn": "clean release (functions)",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/Api"
}
},
{
"type": "func",
"dependsOn": "build",
"dependsOn": "build (functions)",
"options": {
"cwd": "${workspaceFolder}/Api/bin/Debug/net6.0"
"cwd": "${workspaceFolder}/Api/bin/Debug/net8.0"
},
"command": "host start",
"isBackground": true,
"problemMatcher": "$func-watch"
"problemMatcher": "$func-dotnet-watch"
}
]
}
19 changes: 12 additions & 7 deletions Api/Api.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.10.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.2" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
Expand All @@ -19,6 +23,7 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" />
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
<ProjectReference Include="..\Shared\Shared.csproj" />
</ItemGroup>
</Project>
</Project>
25 changes: 10 additions & 15 deletions Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Azure.Functions.Worker.Configuration;

namespace ApiIsolated
{
public class Program
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services =>
{
public static void Main()
{
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
})
.Build();

host.Run();
}
}
}
host.Run();
9 changes: 9 additions & 0 deletions Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"profiles": {
"Api": {
"commandName": "Project",
"commandLineArgs": "--port 7071",
"launchBrowser": false
}
}
}
11 changes: 11 additions & 0 deletions Api/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"dependencies": {
"appInsights1": {
"type": "appInsights"
},
"storage1": {
"type": "storage",
"connectionId": "AzureWebJobsStorage"
}
}
}
11 changes: 11 additions & 0 deletions Api/Properties/serviceDependencies.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"dependencies": {
"appInsights1": {
"type": "appInsights.sdk"
},
"storage1": {
"type": "storage.emulator",
"connectionId": "AzureWebJobsStorage"
}
}
}
4 changes: 1 addition & 3 deletions Api/WeatherForecastFunction.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.Linq;
using System.Net;
using BlazorApp.Shared;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;

namespace ApiIsolated
namespace Api
{
public class HttpTrigger
{
Expand Down
3 changes: 2 additions & 1 deletion Api/host.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
},
"enableLiveMetricsFilters": true
}
}
}
11 changes: 6 additions & 5 deletions Client/Client.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>BlazorApp.Client</RootNamespace>
<RootNamespace>BlazorApp.Client</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
</ItemGroup>


<ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" />
<ProjectReference Include="..\Shared\Shared.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
@inherits LayoutComponentBase

<div class="page">
<div class="sidebar">
<NavMenu />
</div>

<main>
<div class="top-row px-4">
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
</div>

<article class="content px-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ main {
}

@media (max-width: 640.98px) {
.top-row:not(.auth) {
display: none;
}

.top-row.auth {
.top-row {
justify-content: space-between;
}

Expand Down
8 changes: 4 additions & 4 deletions Client/Shared/NavMenu.razor → Client/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
</div>
</div>

<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu">
<nav class="flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> Home
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="oi oi-plus" aria-hidden="true"></span> Counter
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="fetchdata">
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
</NavLink>
</div>
</nav>
Expand Down
Loading

0 comments on commit 83d3458

Please sign in to comment.