From 37e943b1dab5385612e8de52014117e221d13847 Mon Sep 17 00:00:00 2001
From: algo-1 <30294430+algo-1@users.noreply.github.com>
Date: Thu, 12 Sep 2024 12:43:13 +0100
Subject: [PATCH] Upgrade dotnet (#96)
* upgrade console-daemon to dotnet 8
* upgrade web-api-azure-function
* add .gitignore for azure function
* update readme to dotnet 8
* adding .gitattributes for unified line-ending
* Revert "adding .gitattributes for unified line-ending"
This reverts commit ffc2ec9a856e61bd4b621c7f1e391f67faa1dcaa.
* Upgrade console-cli to dotnet 8
* upgrade web-api-obo-client
* upgrade web-api-obo-user
* upgrade web-app-aspnet
* upgrade web-app-blazor-server to dotnet 8
* upgrade desktop-winforms to dotnet 8
* upgrade desktop-winui
* upgrade deaktop-wpf
* update readmes for desktop sample apps
---
console-cli/README.md | 2 +-
console-cli/cli.csproj | 7 +-
console-daemon/Cli.csproj | 11 +-
console-daemon/README.md | 2 +-
desktop-winforms/MsalExample.csproj | 5 +-
desktop-winforms/README.md | 6 +-
desktop-winui/README.md | 4 +-
desktop-winui/WinUIApp.csproj | 6 +-
desktop-wpf/MsalExample.csproj | 25 +-
desktop-wpf/README.md | 6 +-
web-api-azure-function/.gitignore | 264 ++++++++++++++++++
web-api-azure-function/Api.csproj | 5 +-
web-api-azure-function/README.md | 2 +-
web-api-obo-client/Api.csproj | 10 +-
web-api-obo-client/Program.cs | 8 +-
web-api-obo-client/README.md | 2 +-
web-api-obo-client/appsettings.json | 2 +-
web-api-obo-user/Api.csproj | 10 +-
web-api-obo-user/Program.cs | 9 +-
web-api-obo-user/README.md | 4 +-
web-api-obo-user/appsettings.json | 2 +-
web-app-aspnet/Properties/launchSettings.json | 19 ++
web-app-aspnet/README.md | 16 +-
web-app-aspnet/WebApp.csproj | 11 +-
.../BlazorServerWebApp.csproj | 12 +-
web-app-blazor-server/Pages/Index.razor | 45 +--
web-app-blazor-server/Program.cs | 8 +-
web-app-blazor-server/appsettings.json | 2 +-
28 files changed, 384 insertions(+), 121 deletions(-)
create mode 100644 web-api-azure-function/.gitignore
create mode 100644 web-app-aspnet/Properties/launchSettings.json
diff --git a/console-cli/README.md b/console-cli/README.md
index 287162d..bc200ed 100644
--- a/console-cli/README.md
+++ b/console-cli/README.md
@@ -44,7 +44,7 @@ To sign in, use a web browser to open the page https://microsoft.com/devicelogin
## Prerequisites
- Microsoft Entra tenant and the permissions or role required for managing app registrations in the tenant.
-- [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0)
+- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
## Setup
diff --git a/console-cli/cli.csproj b/console-cli/cli.csproj
index 616bb0d..b67d71a 100644
--- a/console-cli/cli.csproj
+++ b/console-cli/cli.csproj
@@ -1,15 +1,12 @@
-
Exe
- net6.0
+ net8.0
App
enable
enable
-
-
+
-
diff --git a/console-daemon/Cli.csproj b/console-daemon/Cli.csproj
index 97e79ae..ead809c 100644
--- a/console-daemon/Cli.csproj
+++ b/console-daemon/Cli.csproj
@@ -1,14 +1,11 @@
-
Exe
- net6.0
+ net8.0
enable
enable
-
-
-
+
+
-
-
+
\ No newline at end of file
diff --git a/console-daemon/README.md b/console-daemon/README.md
index 4491a7d..ada4bf6 100644
--- a/console-daemon/README.md
+++ b/console-daemon/README.md
@@ -42,7 +42,7 @@ Could not find a cached token, so fetching a new one.
## Prerequisites
- An Azure account with an active subscription. If you don't already have one, [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
-- [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0)
+- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
## Setup
diff --git a/desktop-winforms/MsalExample.csproj b/desktop-winforms/MsalExample.csproj
index 8a7a0d1..444aa03 100644
--- a/desktop-winforms/MsalExample.csproj
+++ b/desktop-winforms/MsalExample.csproj
@@ -1,15 +1,12 @@
-
WinExe
- net6.0-windows
+ net8.0-windows
enable
true
enable
-
-
\ No newline at end of file
diff --git a/desktop-winforms/README.md b/desktop-winforms/README.md
index bfc8cba..039649e 100644
--- a/desktop-winforms/README.md
+++ b/desktop-winforms/README.md
@@ -5,7 +5,7 @@ languages:
- csharp
page_type: sample
name: Windows Forms app that makes a request to the Graph API after signing in the user
-description: This .NET 6 Windows Forms app signs in the user and then makes a request to Microsoft Graph for the user's profile data.
+description: This .NET 8 Windows Forms app signs in the user and then makes a request to Microsoft Graph for the user's profile data.
products:
- azure
- entra-id
@@ -26,7 +26,7 @@ This .NET Windows Forms application authenticates a user and then makes a reques
## Prerequisites
- Microsoft Entra tenant and the permissions or role required for managing app registrations in the tenant.
-- Visual Studio 2022, [configured for the .NET 6 desktop development workload](https://docs.microsoft.com/dotnet/desktop/winforms/get-started/create-app-visual-studio?view=netdesktop-6.0#prerequisites)
+- Visual Studio 2022, [configured for the .NET 8 desktop development workload](https://docs.microsoft.com/dotnet/desktop/winforms/get-started/create-app-visual-studio?view=netdesktop-8.0#prerequisites)
## Setup
@@ -71,7 +71,7 @@ The appliction will open allowing you to click the **Sign In (if needed) & Call
## About the code
-This .NET 6 Windows Forms application presents a button that initiates an authentication flow using the Microsoft Authentication Library (MSAL). The user completes this flow in their default web browser. Upon successful authentication, an HTTP GET request to the Microsoft Graph /me endpoint is issued with the user's access token in the HTTP header. The response from the GET request is then displayed to the user. The MSAL client first looks to its token cache, refreshing if necessary, before acquiring a new access token.
+This .NET 8 Windows Forms application presents a button that initiates an authentication flow using the Microsoft Authentication Library (MSAL). The user completes this flow in their default web browser. Upon successful authentication, an HTTP GET request to the Microsoft Graph /me endpoint is issued with the user's access token in the HTTP header. The response from the GET request is then displayed to the user. The MSAL client first looks to its token cache, refreshing if necessary, before acquiring a new access token.
## Reporting problems
diff --git a/desktop-winui/README.md b/desktop-winui/README.md
index 9027f8b..a497892 100644
--- a/desktop-winui/README.md
+++ b/desktop-winui/README.md
@@ -5,7 +5,7 @@ languages:
- csharp
page_type: sample
name: WinUI 3 Packaged Desktop App that makes a request to the Graph API after signing in the user
-description: This .NET 6 (C#) WinUI 3 Packaged Desktop App signs in the user and then makes a request to Microsoft Graph for the user's profile data.
+description: This .NET 8 (C#) WinUI 3 Packaged Desktop App signs in the user and then makes a request to Microsoft Graph for the user's profile data.
products:
- azure
- entra-id
@@ -72,7 +72,7 @@ The application will open allowing you to click the **Sign In (if needed) & Call
## About the code
-This .NET 6 WinUI 3 Packaged Desktop App presents a button that initiates an authentication flow using the Microsoft Authentication Library (MSAL). The user completes this flow in their default web browser. Upon successful authentication, an HTTP GET request to the Microsoft Graph /me endpoint is issued with the user's access token in the HTTP header. The response from the GET request is then displayed to the user. The MSAL client first looks to its token cache, refreshing if necessary, before acquiring a new access token.
+This .NET 8 WinUI 3 Packaged Desktop App presents a button that initiates an authentication flow using the Microsoft Authentication Library (MSAL). The user completes this flow in their default web browser. Upon successful authentication, an HTTP GET request to the Microsoft Graph /me endpoint is issued with the user's access token in the HTTP header. The response from the GET request is then displayed to the user. The MSAL client first looks to its token cache, refreshing if necessary, before acquiring a new access token.
## Reporting problems
diff --git a/desktop-winui/WinUIApp.csproj b/desktop-winui/WinUIApp.csproj
index becfe0e..a2c169c 100644
--- a/desktop-winui/WinUIApp.csproj
+++ b/desktop-winui/WinUIApp.csproj
@@ -1,13 +1,13 @@
WinExe
- net6.0-windows10.0.19041.0
+ net8.0-windows10.0.19041.0
10.0.17763.0
WinUIApp
app.manifest
x86;x64;arm64
- win10-x86;win10-x64;win10-arm64
- win10-$(Platform).pubxml
+ win-x86;win-x64;win-arm64
+ win-$(Platform).pubxml
true
true
diff --git a/desktop-wpf/MsalExample.csproj b/desktop-wpf/MsalExample.csproj
index dbf4bc2..044dd44 100644
--- a/desktop-wpf/MsalExample.csproj
+++ b/desktop-wpf/MsalExample.csproj
@@ -1,15 +1,12 @@
-
-
- WinExe
- net6.0-windows
- enable
- true
- disable
-
-
-
-
-
-
-
+
+ WinExe
+ net8.0-windows
+ enable
+ true
+ disable
+
+
+
+
+
\ No newline at end of file
diff --git a/desktop-wpf/README.md b/desktop-wpf/README.md
index 98eb4e1..79bc918 100644
--- a/desktop-wpf/README.md
+++ b/desktop-wpf/README.md
@@ -5,7 +5,7 @@ languages:
- csharp
page_type: sample
name: Windows Presentation Foundation (WPF) app that makes a request to the Graph API after signing in the user
-description: This .NET 6 (C#) Windows Presentation Foundation (WPF) app signs in the user and then makes a request to Microsoft Graph for the user's profile data.
+description: This .NET 8 (C#) Windows Presentation Foundation (WPF) app signs in the user and then makes a request to Microsoft Graph for the user's profile data.
products:
- azure
- entra-id
@@ -26,7 +26,7 @@ This .NET Windows Presentation Foundation (WPF) application authenticates a user
## Prerequisites
- Microsoft Entra tenant and the permissions or role required for managing app registrations in the tenant.
-- Visual Studio 2022, [configured for the .NET 6 desktop development workload](https://docs.microsoft.com/dotnet/desktop/winforms/get-started/create-app-visual-studio?view=netdesktop-6.0#prerequisites)
+- Visual Studio 2022, [configured for the .NET 8 desktop development workload](https://docs.microsoft.com/dotnet/desktop/winforms/get-started/create-app-visual-studio?view=netdesktop-8.0#prerequisites)
## Setup
@@ -71,7 +71,7 @@ The application will open allowing you to click the **Sign In (if needed) & Call
## About the code
-This .NET 6 Windows Presentation Foundation (WPF) application presents a button that initiates an authentication flow using the Microsoft Authentication Library (MSAL). The user completes this flow in their default web browser. Upon successful authentication, an HTTP GET request to the Microsoft Graph /me endpoint is issued with the user's access token in the HTTP header. The response from the GET request is then displayed to the user. The MSAL client first looks to its token cache, refreshing if necessary, before acquiring a new access token.
+This .NET 8 Windows Presentation Foundation (WPF) application presents a button that initiates an authentication flow using the Microsoft Authentication Library (MSAL). The user completes this flow in their default web browser. Upon successful authentication, an HTTP GET request to the Microsoft Graph /me endpoint is issued with the user's access token in the HTTP header. The response from the GET request is then displayed to the user. The MSAL client first looks to its token cache, refreshing if necessary, before acquiring a new access token.
## Reporting problems
diff --git a/web-api-azure-function/.gitignore b/web-api-azure-function/.gitignore
new file mode 100644
index 0000000..ff5b00c
--- /dev/null
+++ b/web-api-azure-function/.gitignore
@@ -0,0 +1,264 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# Azure Functions localsettings file
+local.settings.json
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+#*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
\ No newline at end of file
diff --git a/web-api-azure-function/Api.csproj b/web-api-azure-function/Api.csproj
index 64bd55e..f6cccce 100644
--- a/web-api-azure-function/Api.csproj
+++ b/web-api-azure-function/Api.csproj
@@ -1,11 +1,10 @@
- net6.0
+ net8.0
v4
- Api
-
+
diff --git a/web-api-azure-function/README.md b/web-api-azure-function/README.md
index f4b074b..eb1a934 100644
--- a/web-api-azure-function/README.md
+++ b/web-api-azure-function/README.md
@@ -31,7 +31,7 @@ Hello, world. You were able to access this because you provided a valid access t
## Prerequisites
- Microsoft Entra tenant and the permissions or role required for managing app registrations in the tenant.
-- [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0)
+- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
- An empty [C# Azure function (v4)](https://docs.microsoft.com/azure/azure-functions/create-first-function-cli-csharp) deployed to Azure, and the permissions or role required to modify its settings.
- [Azure Functions Core Tools](https://docs.microsoft.com/azure/azure-functions/functions-run-local)
diff --git a/web-api-obo-client/Api.csproj b/web-api-obo-client/Api.csproj
index dc6ee0b..4aa0e60 100644
--- a/web-api-obo-client/Api.csproj
+++ b/web-api-obo-client/Api.csproj
@@ -1,13 +1,11 @@
-
- net6.0
+ net8.0
enable
enable
-
-
+
+
-
-
+
\ No newline at end of file
diff --git a/web-api-obo-client/Program.cs b/web-api-obo-client/Program.cs
index e28f118..17652d5 100644
--- a/web-api-obo-client/Program.cs
+++ b/web-api-obo-client/Program.cs
@@ -1,8 +1,8 @@
using System.Text.Json;
//
using Microsoft.AspNetCore.Authentication.JwtBearer;
-using Microsoft.AspNetCore.Authorization;
using Microsoft.Identity.Web;
+using Microsoft.Identity.Abstractions;
//
//
@@ -15,15 +15,15 @@
.AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd"))
.EnableTokenAcquisitionToCallDownstreamApi()
.AddInMemoryTokenCaches()
- .AddDownstreamWebApi("GraphApi", builder.Configuration.GetSection("GraphApi"));
+ .AddDownstreamApi("GraphApi", builder.Configuration.GetSection("GraphApi"));
//
WebApplication app = builder.Build();
//
-app.MapGet("api/application", async (IDownstreamWebApi downstreamWebApi) =>
+app.MapGet("api/application", async (IDownstreamApi downstreamApi) =>
{
- using var response = await downstreamWebApi.CallWebApiForAppAsync("GraphApi").ConfigureAwait(false);
+ using var response = await downstreamApi.CallApiForAppAsync("GraphApi").ConfigureAwait(false);
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
diff --git a/web-api-obo-client/README.md b/web-api-obo-client/README.md
index 2134413..b37a5e3 100644
--- a/web-api-obo-client/README.md
+++ b/web-api-obo-client/README.md
@@ -53,7 +53,7 @@ $ curl https://localhost:5001/api/application
## Prerequisites
- A Microsoft Entra tenant. You can [open an Azure account for free](https://azure.microsoft.com/free) to get a Microsoft Entra instance.
-- [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0)
+- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
## Setup
diff --git a/web-api-obo-client/appsettings.json b/web-api-obo-client/appsettings.json
index 9937689..3f0331f 100644
--- a/web-api-obo-client/appsettings.json
+++ b/web-api-obo-client/appsettings.json
@@ -8,7 +8,7 @@
"GraphApi": {
"BaseUrl": "https://graph.microsoft.com/v1.0/applications",
"RelativePath": "Enter_the_Application_Object_Id_here",
- "Scopes": "https://graph.microsoft.com/.default"
+ "Scopes": ["https://graph.microsoft.com/.default"]
},
"Logging": {
"LogLevel": {
diff --git a/web-api-obo-user/Api.csproj b/web-api-obo-user/Api.csproj
index dc6ee0b..4aa0e60 100644
--- a/web-api-obo-user/Api.csproj
+++ b/web-api-obo-user/Api.csproj
@@ -1,13 +1,11 @@
-
- net6.0
+ net8.0
enable
enable
-
-
+
+
-
-
+
\ No newline at end of file
diff --git a/web-api-obo-user/Program.cs b/web-api-obo-user/Program.cs
index e54e311..a3419f0 100644
--- a/web-api-obo-user/Program.cs
+++ b/web-api-obo-user/Program.cs
@@ -2,7 +2,9 @@
//
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
+using Microsoft.Identity.Abstractions;
using Microsoft.Identity.Web;
+
//
//
@@ -14,7 +16,7 @@
// the on-behalf-of access token, per user-assertion, based on the provided access
// token to this API.
.AddInMemoryTokenCaches()
- .AddDownstreamWebApi("GraphApi", builder.Configuration.GetSection("GraphApi"));
+ .AddDownstreamApi("GraphApi", builder.Configuration.GetSection("GraphApi"));
builder.Services.AddAuthorization();
//
@@ -25,8 +27,9 @@
//
//
-app.MapGet("/api/me", [Authorize()] async (IDownstreamWebApi downstreamWebApi) => {
- var response = await downstreamWebApi.CallWebApiForUserAsync("GraphApi").ConfigureAwait(false);
+app.MapGet("/api/me", [Authorize()] async (IDownstreamApi downstreamWebApi) =>
+{
+ var response = await downstreamWebApi.CallApiForUserAsync("GraphApi").ConfigureAwait(false);
var graphApiResponse = await response.Content.ReadFromJsonAsync().ConfigureAwait(false);
return JsonSerializer.Serialize(graphApiResponse, new JsonSerializerOptions { WriteIndented = true });
diff --git a/web-api-obo-user/README.md b/web-api-obo-user/README.md
index 288a82d..ed96ff5 100644
--- a/web-api-obo-user/README.md
+++ b/web-api-obo-user/README.md
@@ -19,7 +19,7 @@ urlFragment: ms-identity-docs-code-obo-user-csharp
  
-->
-This ASP.NET Core minimal web API uses the Microsoft identity platform to protect an endpoint (require authorized access), and also accesses Microsoft Graph on behalf of the user. The API uses [ASP.NET Core Identity](https://docs.microsoft.com/aspnet/core/security/authentication/identity?view=aspnetcore-6.0) interacting with the [Microsoft Authentication Library (MSAL)](https://docs.microsoft.com/azure/active-directory/develop/msal-overview) to protect its endpoint.
+This ASP.NET Core minimal web API uses the Microsoft identity platform to protect an endpoint (require authorized access), and also accesses Microsoft Graph on behalf of the user. The API uses [ASP.NET Core Identity](https://docs.microsoft.com/aspnet/core/security/authentication/identity?view=aspnetcore-8.0) interacting with the [Microsoft Authentication Library (MSAL)](https://docs.microsoft.com/azure/active-directory/develop/msal-overview) to protect its endpoint.
```console
$ curl https://localhost:5001/api/me -H "Authorization: Bearer {valid-access-token}"
@@ -43,7 +43,7 @@ $ curl https://localhost:5001/api/me -H "Authorization: Bearer {valid-access-tok
## Prerequisites
- A Microsoft Entra tenant. You can [open an Azure account for free](https://azure.microsoft.com/free) to get a Microsoft Entra instance.
-- [.NET 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0)
+- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
## Setup
diff --git a/web-api-obo-user/appsettings.json b/web-api-obo-user/appsettings.json
index 08c9f13..8074aec 100644
--- a/web-api-obo-user/appsettings.json
+++ b/web-api-obo-user/appsettings.json
@@ -7,7 +7,7 @@
},
"GraphApi": {
"BaseUrl": "https://graph.microsoft.com/v1.0/me",
- "Scopes": "user.read"
+ "Scopes": ["user.read"]
},
"Logging": {
"LogLevel": {
diff --git a/web-app-aspnet/Properties/launchSettings.json b/web-app-aspnet/Properties/launchSettings.json
new file mode 100644
index 0000000..6ce576a
--- /dev/null
+++ b/web-app-aspnet/Properties/launchSettings.json
@@ -0,0 +1,19 @@
+{
+ "profiles": {
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "WebApplication1": {
+ "commandName": "Project",
+ "launchBrowser": true,
+ "applicationUrl": "https://localhost:5001;http://localhost:5000",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/web-app-aspnet/README.md b/web-app-aspnet/README.md
index 6dfa0b1..812ad4d 100644
--- a/web-app-aspnet/README.md
+++ b/web-app-aspnet/README.md
@@ -4,8 +4,8 @@
languages:
- csharp
page_type: sample
-name: "ASP.NET Core 6.0 Web App Sign-in user"
-description: "This is a ASP.NET Core 6.0 Web App that sign-in users. The code in this sample is used by one or more articles on docs.microsoft.com."
+name: "ASP.NET Core 8.0 Web App Sign-in user"
+description: "This is a ASP.NET Core 8.0 Web App that sign-in users. The code in this sample is used by one or more articles on docs.microsoft.com."
products:
- azure
- entra-id
@@ -13,9 +13,9 @@ products:
urlFragment: ms-identity-docs-code-csharp-sign-in
---
-# ASP.NET Core 6.0 Web App - Sign-in user | Microsoft identity platform
+# ASP.NET Core 8.0 Web App - Sign-in user | Microsoft identity platform
-This web app, built with ASP.NET Core 6.0 Razor, has added sign-in features. It uses the [OpenID Connect](https://docs.microsoft.com/en-us/entra/identity-platform/v2-protocols-oidc) and [ASP.NET Core Identity](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-6.0) for authentication. This allows users to sign in with their Microsoft Entra accounts. Once signed in, the app can access protected resources on the user’s behalf.
+This web app, built with ASP.NET Core 8.0 Razor, has added sign-in features. It uses the [OpenID Connect](https://docs.microsoft.com/en-us/entra/identity-platform/v2-protocols-oidc) and [ASP.NET Core Identity](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-8.0) for authentication. This allows users to sign in with their Microsoft Entra accounts. Once signed in, the app can access protected resources on the user’s behalf.
## Quickstart and tutorial guides for this sample
@@ -82,19 +82,19 @@ Use the following settings for your app registration:
1. Once the web app is listening, navigate to https://localhost:5001
1. Sign-in with your user credentials.
-
+
### 3. Sign out
1. Select Sign out
-
+
## About the code
-The ASP.NET Core 6.0 Web App will allow users to sign-in, so it can retrieve a Security Token scoped specifically for the Microsoft Graph API, and will use that token to access the user's information. For more information about the proposed scenario, please take a look at the following diagram:
+The ASP.NET Core 8.0 Web App will allow users to sign-in, so it can retrieve a Security Token scoped specifically for the Microsoft Graph API, and will use that token to access the user's information. For more information about the proposed scenario, please take a look at the following diagram:
-:link: For more information about how to proctect your projects, please let's take a look at https://docs.microsoft.com/en-us/azure/active-directory/develop/sample-v2-code. To know more about how this sample has been generated, please visit https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/?view=aspnetcore-6.0
+:link: For more information about how to proctect your projects, please let's take a look at https://docs.microsoft.com/en-us/azure/active-directory/develop/sample-v2-code. To know more about how this sample has been generated, please visit https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/?view=aspnetcore-8.0
## Reporting problems
diff --git a/web-app-aspnet/WebApp.csproj b/web-app-aspnet/WebApp.csproj
index 72e6a0d..1f984ff 100644
--- a/web-app-aspnet/WebApp.csproj
+++ b/web-app-aspnet/WebApp.csproj
@@ -1,17 +1,14 @@
-
- net6.0
+ net8.0
enable
enable
aspnet-sign_in_webapp-B0B85736-C285-4B12-8C9F-8E3C25987A0A
sign_in_webapp
-
-
-
+
+
-
-
+
\ No newline at end of file
diff --git a/web-app-blazor-server/BlazorServerWebApp.csproj b/web-app-blazor-server/BlazorServerWebApp.csproj
index 926d9b6..f0c1a79 100644
--- a/web-app-blazor-server/BlazorServerWebApp.csproj
+++ b/web-app-blazor-server/BlazorServerWebApp.csproj
@@ -1,14 +1,12 @@
-
- net6.0
+ net8.0
enable
enable
-
-
-
+
+
+
-
-
+
\ No newline at end of file
diff --git a/web-app-blazor-server/Pages/Index.razor b/web-app-blazor-server/Pages/Index.razor
index eed2194..be1931e 100644
--- a/web-app-blazor-server/Pages/Index.razor
+++ b/web-app-blazor-server/Pages/Index.razor
@@ -1,11 +1,13 @@
-@using Microsoft.Identity.Web;
+@using Microsoft.Identity.Abstractions;
+@using Microsoft.Identity.Web;
@using System.Text.Json
-@inject IDownstreamWebApi downstreamWebApi
+@inject IDownstreamApi downstreamApi
@inject MicrosoftIdentityConsentAndConditionalAccessHandler ConsentHandler
@page "/"
-ASP.NET Core 6.0 Blazor Server | user sign-in, protected web API access (Microsoft Graph) | Microsoft identity platform
+ASP.NET Core 6.0 Blazor Server | user sign-in, protected web API access (Microsoft Graph) | Microsoft
+ identity platform
Welcome to User Sign In ASP.NET Core Blazor Server
@@ -13,31 +15,34 @@
@if (graphApiResponse != null)
{
- Before rendering the page, the controller was able to make a call to
- Microsoft Graph's /me
API for your user and received the
- following:
+ Before rendering the page, the controller was able to make a call to
+ Microsoft Graph's /me
API for your user and received the
+ following:
- @JsonSerializer.Serialize(graphApiResponse, new JsonSerializerOptions { WriteIndented = true })
+
+
@JsonSerializer.Serialize(graphApiResponse, new JsonSerializerOptions { WriteIndented = true })
+
- Refreshing this page will continue to use the cached access token acquired for Microsoft Graph, which is valid for future page views will attempt to refresh this token as it nears its expiration.
+ Refreshing this page will continue to use the cached access token acquired for Microsoft Graph, which is valid
+ for future page views will attempt to refresh this token as it nears its expiration.
}
@code {
- private JsonDocument graphApiResponse = null;
+ private JsonDocument graphApiResponse = null;
- protected override async Task OnInitializedAsync()
+ protected override async Task OnInitializedAsync()
+ {
+ try
+ {
+ using var response = await downstreamApi.CallApiForUserAsync("GraphApi").ConfigureAwait(false);
+ response.EnsureSuccessStatusCode();
+ graphApiResponse = await response.Content.ReadFromJsonAsync().ConfigureAwait(false);
+ }
+ catch (Exception ex)
{
- try
- {
- using var response = await downstreamWebApi.CallWebApiForUserAsync("GraphApi").ConfigureAwait(false);
- response.EnsureSuccessStatusCode();
- graphApiResponse = await response.Content.ReadFromJsonAsync().ConfigureAwait(false);
- }
- catch (Exception ex)
- {
- ConsentHandler.HandleException(ex);
- }
+ ConsentHandler.HandleException(ex);
}
}
+ }
diff --git a/web-app-blazor-server/Program.cs b/web-app-blazor-server/Program.cs
index dbe72bb..1fcba52 100644
--- a/web-app-blazor-server/Program.cs
+++ b/web-app-blazor-server/Program.cs
@@ -1,9 +1,3 @@
-using Microsoft.AspNetCore.Authentication;
-using Microsoft.AspNetCore.Authentication.OpenIdConnect;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Components;
-using Microsoft.AspNetCore.Components.Web;
-using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.UI;
@@ -12,7 +6,7 @@
builder.Services.AddMicrosoftIdentityWebAppAuthentication(builder.Configuration, "AzureAd")
.EnableTokenAcquisitionToCallDownstreamApi(initialScopes)
- .AddDownstreamWebApi("GraphApi", builder.Configuration.GetSection("GraphApi"))
+ .AddDownstreamApi("GraphApi", builder.Configuration.GetSection("GraphApi"))
.AddInMemoryTokenCaches();
builder.Services.AddControllersWithViews()
diff --git a/web-app-blazor-server/appsettings.json b/web-app-blazor-server/appsettings.json
index f50cee1..4943e71 100644
--- a/web-app-blazor-server/appsettings.json
+++ b/web-app-blazor-server/appsettings.json
@@ -14,7 +14,7 @@ For more info see https://aka.ms/dotnet-template-ms-identity-platform
},
"GraphApi": {
"BaseUrl": "https://graph.microsoft.com/v1.0/me",
- "Scopes": "user.read"
+ "Scopes": ["user.read"]
},
"Logging": {
"LogLevel": {