Skip to content

Commit 08d7db1

Browse files
committed
Merging changes synced from https://github.com/MicrosoftDocs/azure-docs-pr (branch live)
2 parents ce1461f + e8cb06b commit 08d7db1

File tree

81 files changed

+1237
-879
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1237
-879
lines changed

articles/active-directory/develop/includes/console-app/quickstart-netcore.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ This quickstart requires [.NET Core 6.0 SDK](https://dotnet.microsoft.com/downlo
2727

2828
## Register and download the app
2929

30-
3130
The application can be built using either an automatic or manual configuration.
3231

3332
### Automatic configuration
@@ -60,20 +59,16 @@ To register the application and add the registration information to the solution
6059

6160
#### Step 2: Download your Visual Studio project
6261

63-
6462
[Download the Visual Studio project](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/archive/master.zip)
6563

66-
This project can be run in either Visual Studio or Visual Studio for Mac and can be downloaded from the [code sample](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/archive/master.zip).
67-
64+
This project can be run in either Visual Studio or Visual Studio for Mac and can be downloaded from the [code sample](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/archive/master.zip).
6865

6966
[!INCLUDE [active-directory-develop-path-length-tip](../../../../../includes/active-directory-develop-path-length-tip.md)]
7067

71-
7268
#### Step 3: Configure your Visual Studio project
7369

7470
1. Extract the *.zip* file to a local folder that's close to the root of the disk to avoid errors caused by path length limitations on Windows. For example, extract to *C:\Azure-Samples*.
7571

76-
7772
1. Open the solution in Visual Studio: *1-Call-MSGraph\daemon-console.sln* (optional).
7873
1. In *appsettings.json*, replace the values of `Tenant`, `ClientId`, and `ClientSecret`. The value for the application (client) ID and the directory (tenant) ID, can be found in the app's **Overview** page on the Azure portal.
7974

@@ -89,7 +84,6 @@ This project can be run in either Visual Studio or Visual Studio for Mac and can
8984
- Replace `Enter_the_Client_Secret_Here` with the client secret that you created in step 1.
9085
To generate a new key, go to the **Certificates & secrets** page.
9186

92-
9387
#### Step 4: Admin consent
9488

9589
Running the application now results in the output `HTTP 403 - Forbidden* error: "Insufficient privileges to complete the operation`. This error occurs because any app-only permission requires a global administrator of the directory to give consent to the application. Select one of the following options, depending on the role.
@@ -98,7 +92,6 @@ Running the application now results in the output `HTTP 403 - Forbidden* error:
9892

9993
For a global tenant administrator, go to **Enterprise applications** in the Azure portal. Select the app registration, and select **Permissions** from the **Security** section of the left pane. Then select the large button labeled **Grant admin consent for {Tenant Name}** (where **{Tenant Name}** is the name of the directory).
10094

101-
10295
##### Standard user
10396

10497
For a standard user of your tenant, ask a global administrator to grant admin consent to the application. To do this, provide the following URL to the administrator:
@@ -108,8 +101,9 @@ https://login.microsoftonline.com/Enter_the_Tenant_Id_Here/adminconsent?client_i
108101
```
109102

110103
In the URL:
111-
* Replace `Enter_the_Tenant_Id_Here` with the tenant ID or tenant name (for example, `contoso.microsoft.com`).
112-
* `Enter_the_Application_Id_Here` is the application (client) ID for the registered application.
104+
105+
- Replace `Enter_the_Tenant_Id_Here` with the tenant ID or tenant name (for example, `contoso.microsoft.com`).
106+
- `Enter_the_Application_Id_Here` is the application (client) ID for the registered application.
113107

114108
The error `AADSTS50011: No reply address is registered for the application` may be displayed after you grant consent to the app by using the preceding URL. This error occurs because the application and the URL don't have a redirect URI. This can be ignored.
115109

@@ -121,12 +115,14 @@ In Visual Studio, press **F5** to run the application. Otherwise, run the applic
121115
cd {ProjectFolder}\1-Call-MSGraph\daemon-console
122116
dotnet run
123117
```
118+
124119
In that code:
125-
* `{ProjectFolder}` is the folder where you extracted the .zip file. An example is `C:\Azure-Samples\active-directory-dotnetcore-daemon-v2`.
120+
121+
- `{ProjectFolder}` is the folder where you extracted the .zip file. An example is `C:\Azure-Samples\active-directory-dotnetcore-daemon-v2`.
126122

127123
A list of users in Azure Active Directory should be displayed as a result.
128124

129-
This quickstart application uses a client secret to identify itself as a confidential client. The client secret is added as a plain-text file to the project files. For security reasons, we recommend to use a certificate instead of a client secret before considering the application as a production application. For more information on how to use a certificate, see [these instructions](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/#variation-daemon-application-using-client-credentials-with-certificates).
125+
This quickstart application uses a client secret to identify itself as a confidential client. The client secret is added as a plain-text file to the project files. For security reasons, it is recommended to use a certificate instead of a client secret before considering the application as a production application. For more information on how to use a certificate, see [these instructions](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/#variation-daemon-application-using-client-credentials-with-certificates).
130126

131127
## More information
132128

articles/active-directory/develop/includes/web-api/quickstart-aspnet-core.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ First, register the web API in your Azure AD tenant and add a scope by following
4949

5050
> [!Note]
5151
> The code sample currently targets ASP.NET Core 3.1. The sample can be updated to use .NET Core 6.0 and is covered in the following steps: [Update the sample code to ASP.NET Core 6.0](#step-4-update-the-sample-code-to-aspnet-core-60)
52-
This quickstart will be deprecated in the near future and will be updated to use .NET 6.0.
52+
This quickstart will be deprecated in the near future and will be updated to use .NET 6.0.
5353

5454
## Step 3: Configure the ASP.NET Core project
5555

@@ -90,7 +90,7 @@ To update this code sample to target ASP.NET Core 6.0, follow these steps:
9090
<TargetFramework>netcoreapp6.0</TargetFramework>
9191
```
9292

93-
This step will ensure that the sample is targeting .NET 6.0.
93+
This step will ensure that the sample is targeting the .NET Core 6.0 framework.
9494

9595
### Step 5: Run the sample
9696

articles/active-directory/develop/includes/web-api/quickstart-dotnet-native-aspnet.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ms.custom: devx-track-csharp, aaddev, identityplatformtop40, "scenarios:getting-
1414
#Customer intent: As an application developer, I want to know how to set up OpenId Connect authentication in a web application that's built by using Node.js with Express.
1515
---
1616

17-
The following quickstart uses quickstart, uses a code sample that demonstrates how to protect an ASP.NET web API by restricting access to its resources to authorized accounts only. The sample supports authorization of personal Microsoft accounts and accounts in any Azure Active Directory (Azure AD) organization.
17+
The following quickstart uses, uses a code sample that demonstrates how to protect an ASP.NET web API by restricting access to its resources to authorized accounts only. The sample supports authorization of personal Microsoft accounts and accounts in any Azure Active Directory (Azure AD) organization.
1818

1919
The article also uses a Windows Presentation Foundation (WPF) app to demonstrate how to request an access token to access a web API.
2020

articles/active-directory/develop/quickstart-v2-aspnet-core-web-api.md

Lines changed: 80 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.service: active-directory
88
ms.subservice: develop
99
ms.topic: portal
1010
ms.workload: identity
11-
ms.date: 01/11/2022
11+
ms.date: 12/09/2022
1212
ROBOTS: NOINDEX
1313
ms.author: jmprieur
1414
ms.custom: devx-track-csharp, "scenarios:getting-started", "languages:aspnet-core", mode-api
@@ -25,67 +25,114 @@ ms.custom: devx-track-csharp, "scenarios:getting-started", "languages:aspnet-cor
2525
> We apologize for the inconvenience and appreciate your patience while we work to get this resolved.
2626
2727
> [!div renderon="portal" class="sxs-lookup"]
28-
> In this quickstart, you download an ASP.NET Core web API code sample and review the way it restricts resource access to authorized accounts only. The sample supports authorization of personal Microsoft accounts and accounts in any Azure Active Directory (Azure AD) organization.
29-
>
30-
>
28+
> The following quickstart uses a ASP.NET Core web API code sample to demonstrate how to restrict resource access to authorized accounts. The sample supports authorization of personal Microsoft accounts and accounts in any Azure Active Directory (Azure AD) organization.
29+
>
30+
>
3131
> ## Prerequisites
3232
>
3333
> - Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
3434
> - [Azure Active Directory tenant](quickstart-create-new-tenant.md)
35-
> - [.NET Core SDK 3.1+](https://dotnet.microsoft.com/)
36-
> - [Visual Studio 2019](https://visualstudio.microsoft.com/vs/) or [Visual Studio Code](https://code.visualstudio.com/)
35+
> - [.NET Core SDK 6.0+](https://dotnet.microsoft.com/)
36+
> - [Visual Studio 2022](https://visualstudio.microsoft.com/vs/) or [Visual Studio Code](https://code.visualstudio.com/)
3737
>
3838
> ## Step 1: Register the application
3939
>
4040
> First, register the web API in your Azure AD tenant and add a scope by following these steps:
4141
>
4242
> 1. Sign in to the [Azure portal](https://portal.azure.com/).
43-
> 1. If you have access to multiple tenants, use the **Directories + subscriptions** filter :::image type="icon" source="./media/common/portal-directory-subscription-filter.png" border="false"::: in the top menu to switch to the tenant in which you want to register the application.
43+
> 1. If access to multiple tenants is available, use the **Directories + subscriptions** filter :::image type="icon" source=".\media\common\portal-directory-subscription-filter.png" border="false"::: in the top menu to switch to the tenant in which to register the application.
4444
> 1. Search for and select **Azure Active Directory**.
4545
> 1. Under **Manage**, select **App registrations** > **New registration**.
46-
> 1. For **Name**, enter a name for your application. For example, enter **AspNetCoreWebApi-Quickstart**. Users of your app will see this name, and you can change it later.
46+
> 1. For **Name**, enter a name for the application. For example, enter **AspNetCoreWebApi-Quickstart**. Users of the app will see this name, and can be changed later.
4747
> 1. Select **Register**.
48-
> 1. Under **Manage**, select **Expose an API** > **Add a scope**. For **Application ID URI**, accept the default by selecting **Save and continue**, and then enter the following details:
49-
> - **Scope name**: `access_as_user`
50-
> - **Who can consent?**: **Admins and users**
51-
> - **Admin consent display name**: `Access AspNetCoreWebApi-Quickstart`
52-
> - **Admin consent description**: `Allows the app to access AspNetCoreWebApi-Quickstart as the signed-in user.`
53-
> - **User consent display name**: `Access AspNetCoreWebApi-Quickstart`
54-
> - **User consent description**: `Allow the application to access AspNetCoreWebApi-Quickstart on your behalf.`
55-
> - **State**: **Enabled**
48+
> 1. Under **Manage**, select **Expose an API** > **Add a scope**. For **Application ID URI**, accept the default by selecting **Save and continue**, and then enter the following details:
49+
> - **Scope name**: `access_as_user`
50+
> - **Who can consent?**: **Admins and users**
51+
> - **Admin consent display name**: `Access AspNetCoreWebApi-Quickstart`
52+
> - **Admin consent description**: `Allows the app to access AspNetCoreWebApi-Quickstart as the signed-in user.`
53+
> - **User consent display name**: `Access AspNetCoreWebApi-Quickstart`
54+
> - **User consent description**: `Allow the application to access AspNetCoreWebApi-Quickstart on your behalf.`
55+
> - **State**: **Enabled**
5656
> 1. Select **Add scope** to complete the scope addition.
5757
>
5858
> ## Step 2: Download the ASP.NET Core project
5959
>
6060
> [Download the ASP.NET Core solution](https://github.com/Azure-Samples/active-directory-dotnet-native-aspnetcore-v2/archive/aspnetcore3-1.zip) from GitHub.
61-
>
62-
> [!INCLUDE [active-directory-develop-path-length-tip](../../../includes/active-directory-develop-path-length-tip.md)]
61+
>
62+
> > [!Note]
63+
> The code sample currently targets ASP.NET Core 3.1. The sample can be updated to use .NET Core 6.0 and is covered in the following steps: [Update the sample code to ASP.NET Core 6.0](#step-4-update-the-sample-code-to-aspnet-core-60).
64+
This quickstart will be deprecated in the near future and will be updated to use .NET 6.0.
65+
>
6366
>
6467
>
6568
> ## Step 3: Configure the ASP.NET Core project
6669
>
67-
> In this step, configure the sample code to work with the app registration that you created earlier.
68-
>
69-
> 1. Extract the .zip archive into a folder near the root of your drive. For example, extract into *C:\Azure-Samples*.
70-
>
71-
> We recommend extracting the archive into a directory near the root of your drive to avoid errors caused by path length limitations on Windows.
70+
> In this step, the sample code will be configured to work with the app registration that was created earlier.
7271
>
72+
> 1. Extract the *.zip* file to a local folder that's close to the root of the disk to avoid errors caused by path length limitations on Windows. For example, extract to *C:\Azure-Samples*.
73+
>
7374
> 1. Open the solution in the *webapi* folder in your code editor.
74-
> 1. Open the *appsettings.json* file and modify the following code:
75+
> 1. In *appsettings.json*, replace the values of `ClientId`, and `TenantId`.
7576
>
7677
> ```json
7778
> "ClientId": "Enter_the_Application_Id_here",
7879
> "TenantId": "Enter_the_Tenant_Info_Here"
7980
> ```
8081
>
81-
> - Replace `Enter_the_Application_Id_here` with the application (client) ID of the application that you registered in the Azure portal. You can find the application (client) ID on the app's **Overview** page.
82+
> - `Enter_the_Application_Id_Here` is the application (client) ID for the registered application.
8283
> - Replace `Enter_the_Tenant_Info_Here` with one of the following:
83-
> - If your application supports **Accounts in this organizational directory only**, replace this value with the directory (tenant) ID (a GUID) or tenant name (for example, `contoso.onmicrosoft.com`). You can find the directory (tenant) ID on the app's **Overview** page.
84-
> - If your application supports **Accounts in any organizational directory**, replace this value with `organizations`.
85-
> - If your application supports **All Microsoft account users**, leave this value as `common`.
84+
> - If the application supports **Accounts in this organizational directory only**, replace this value with the directory (tenant) ID (a GUID) or tenant name (for example, `contoso.onmicrosoft.com`). The directory (tenant) ID can be found on the app's **Overview** page.
85+
> - If the application supports **Accounts in any organizational directory**, replace this value with `organizations`.
86+
> - If the application supports **All Microsoft account users**, leave this value as `common`.
8687
>
8788
> For this quickstart, don't change any other values in the *appsettings.json* file.
8889
>
90+
> ### Step 4: Update the sample code to ASP.NET Core 6.0
91+
>
92+
> To update this code sample to target ASP.NET Core 6.0, follow these steps:
93+
>
94+
>1. Open webapi.csproj
95+
>1. Remove the following line:
96+
>
97+
> ```xml
98+
> <TargetFramework>netcoreapp3.1</TargetFramework>
99+
> ```
100+
>
101+
>1. Add the following line in its place:
102+
>
103+
> ```xml
104+
> <TargetFramework>netcoreapp6.0</TargetFramework>
105+
> ```
106+
>
107+
> This step will ensure that the sample is targeting the .NET Core 6.0 framework.
108+
>
109+
> ### Step 5: Run the sample
110+
>
111+
> 1. Open a terminal and change directory to the project folder.
112+
>
113+
> ```powershell
114+
> cd webapi
115+
> ```
116+
>
117+
> 1. Run the following command to build the solution:
118+
>
119+
> ```powershell
120+
> dotnet run
121+
> ```
122+
>
123+
> If the build has been successful, the following output is displayed:
124+
>
125+
> ```powershell
126+
> Building...
127+
> info: Microsoft.Hosting.Lifetime[0]
128+
> Now listening on: https://localhost:{port}
129+
> info: Microsoft.Hosting.Lifetime[0]
130+
> Now listening on: http://localhost:{port}
131+
> info: Microsoft.Hosting.Lifetime[0]
132+
> Application started. Press Ctrl+C to shut down.
133+
> ...
134+
> ```
135+
>
89136
> ## How the sample works
90137
>
91138
> The web API receives a token from a client application, and the code in the web API validates the token. This scenario is explained in more detail in [Scenario: Protected web API](scenario-protected-web-api-overview.md).
@@ -104,9 +151,10 @@ ms.custom: devx-track-csharp, "scenarios:getting-started", "languages:aspnet-cor
104151
>
105152
> The `AddAuthentication()` method configures the service to add JwtBearer-based authentication.
106153
>
107-
> The line that contains `.AddMicrosoftIdentityWebApi` adds the Microsoft identity platform authorization to your web API. It's then configured to validate access tokens issued by the Microsoft identity platform based on the information in the `AzureAD` section of the *appsettings.json* configuration file:
154+
> The line that contains `.AddMicrosoftIdentityWebApi` adds the Microsoft identity platform authorization to the web API. It's then configured to validate access tokens issued by the Microsoft identity platform based on the information in the `AzureAD` section of the *appsettings.json* configuration file:
108155
>
109-
> | *appsettings.json* key | Description |
156+
> | *appsettings.json* key | Description
157+
|
110158
> |------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
111159
> | `ClientId` | Application (client) ID of the application registered in the Azure portal. |
112160
> | `Instance` | Security token service (STS) endpoint for the user to authenticate. This value is typically `https://login.microsoftonline.com/`, indicating the Azure public cloud. |
@@ -127,7 +175,7 @@ ms.custom: devx-track-csharp, "scenarios:getting-started", "languages:aspnet-cor
127175
>
128176
> ### Protecting a controller, a controller's method, or a Razor page
129177
>
130-
> You can protect a controller or controller methods by using the `[Authorize]` attribute. This attribute restricts access to the controller or methods by allowing only authenticated users. An authentication challenge can be started to access the controller if the user isn't authenticated.
178+
> A controller or controller methods can be protected by using the `[Authorize]` attribute. This attribute restricts access to the controller or methods by allowing only authenticated users. An authentication challenge can be started to access the controller if the user isn't authenticated.
131179
>
132180
> ```csharp
133181
> namespace webapi.Controllers
@@ -168,7 +216,7 @@ ms.custom: devx-track-csharp, "scenarios:getting-started", "languages:aspnet-cor
168216
>
169217
> ## Next steps
170218
>
171-
> The GitHub repository that contains this ASP.NET Core web API code sample includes instructions and more code samples that show you how to:
219+
> The following GitHub repository contains the ASP.NET Core web API code sample instructions and more samples that show how to achieve the following:
172220
>
173221
> - Add authentication to a new ASP.NET Core web API.
174222
> - Call the web API from a desktop application.

0 commit comments

Comments
 (0)