|
1 | 1 | ---
|
2 |
| -title: Use the Microsoft Identity platform connected service to use Microsoft Entra ID for authentication |
3 |
| -description: Connect Microsoft Entra ID (formerly Azure Active Directory) to your application by using Connected Services in Visual Studio on Windows. |
| 2 | +title: Entra ID Authentication With Connected Services |
| 3 | +description: Connect Microsoft Entra ID (formerly Azure Active Directory) to your application with Connected Services in Visual Studio on Windows. |
4 | 4 | author: ghogen
|
5 | 5 | manager: mijacobs
|
6 | 6 | ms.subservice: azure-development
|
7 | 7 | ms.custom: devx-track-csharp
|
8 | 8 | ms.topic: how-to
|
9 |
| -ms.date: 12/19/2023 |
| 9 | +ms.date: 06/27/2025 |
10 | 10 | ms.author: ghogen
|
| 11 | +#customer intent: As a developer, I want to use Connected Services in Visual Studio on Windows, so I can connect Microsoft Entra ID with my application for authentication. |
11 | 12 | ---
|
12 | 13 |
|
13 |
| -# Add Microsoft Entra ID authentication by using Connected Services in Visual Studio |
| 14 | +# Add Microsoft Entra ID authentication with Connected Services in Visual Studio |
14 | 15 |
|
15 |
| -You can add support for Microsoft Entra ID to an ASP.NET web app by using the Microsoft Identity platform connected service. |
| 16 | +You can add support for Microsoft Entra ID to an ASP.NET web application with the Microsoft identity platform connected service. Microsoft Entra ID enables support for user authentication to ASP.NET Model-View-Controller (MVC) web apps or Active Directory Authentication in web API services. |
16 | 17 |
|
17 |
| -By using Microsoft Entra ID, you can support user authentication for ASP.NET Model-View-Controller (MVC) web applications, or Active Directory Authentication in web API services. With Microsoft Entra authentication, your users can use their accounts from Microsoft Entra ID to connect to your web applications. The advantages of Microsoft Entra authentication with web API include enhanced data security when exposing an API from a web application. With Microsoft Entra ID, you do not have to manage a separate authentication system with its own account and user management. |
| 18 | +Microsoft Entra ID authentication offers many advantages: |
18 | 19 |
|
19 |
| -This article and its companion articles provide details of using the Visual Studio Connected Service feature for Active Directory. |
| 20 | +- Users can authenticate with their accounts from Microsoft Entra ID to connect to your web apps. |
| 21 | +- You gain enhanced data security when you expose an API from a web app. |
| 22 | +- You don't have to manage a separate authentication system with its own account and user management. |
| 23 | + |
| 24 | +This article and its [companion articles](#related-content) describe how to use the Visual Studio Connected Service feature for Active Directory. |
20 | 25 |
|
21 | 26 | ## Prerequisites
|
22 | 27 |
|
| 28 | +To complete the procedures in this article, the following prerequisites must be satisfied: |
| 29 | + |
23 | 30 | - [!INCLUDE [prerequisites-azure-subscription](includes/prerequisites-azure-subscription.md)]
|
24 |
| -- **Visual Studio 2015** or later. [Download Visual Studio now](https://aka.ms/vsdownload?utm_source=mscom&utm_campaign=msdocs). |
25 | 31 |
|
26 |
| -<a name='connect-to-azure-active-directory-using-the-connected-services-dialog'></a> |
| 32 | +- **Visual Studio**. [Download Visual Studio now](https://aka.ms/vsdownload?utm_source=mscom&utm_campaign=msdocs). |
27 | 33 |
|
28 |
| -### Connect to Microsoft Identity platform |
| 34 | +## Connect to Microsoft identity platform |
29 | 35 |
|
30 |
| -:::moniker range=">=vs-2022" |
| 36 | +Add Microsoft identity platform as a connected service to your application by following these steps: |
31 | 37 |
|
32 | 38 | 1. In Visual Studio, create or open an ASP.NET MVC project, or an ASP.NET Web API project.
|
33 | 39 |
|
34 |
| -1. Select the **Project**, **Connected Services**, **Add** menu command, or right-click the **Connected Services** node found under the project in Solution Explorer, and choose **Add**, **Microsoft Identity platform**. |
35 |
| - |
36 |
| - If you are missing the .NET MSIdentity tool, the screen prompts you to install it. |
37 |
| - |
38 |
| -  |
39 |
| - |
40 |
| -1. The **Configure Microsoft identity platform** screen appears. If you haven't signed in to Azure, you're asked to sign in. Once you're signed in, you see a list of your applications. |
| 40 | +1. Use one of the following methods to add the Microsoft identity platform connected service: |
41 | 41 |
|
42 |
| -  |
| 42 | + :::moniker range=">=vs-2022" |
43 | 43 |
|
44 |
| -1. If you don't have an application, choose **Create new**, and enter the application name. For Microsoft Entra ID, choose Microsoft as the tenant. |
| 44 | + - Select **Project** > **Connected Services** > **Add** > **Microsoft identity platform**. |
| 45 | + |
| 46 | + - In **Solution Explorer**, right-click the **Connected Services** node for the project, and select **Add** > **Microsoft identity platform**. |
45 | 47 |
|
46 |
| -  |
| 48 | + :::moniker-end |
| 49 | + :::moniker range="<=vs-2019" |
47 | 50 |
|
48 |
| - The application you entered now shows in the list. Select it and choose **Next**. |
| 51 | + - Select **Project** > **Manage Connected Services** > **Add a service dependency** > **Microsoft identity platform**. |
| 52 | + |
| 53 | + - In **Solution Explorer**, right-click the **Connected Services** node for the project, and select **Manage Connected Services > Add a service dependency** > **Microsoft identity platform**. |
49 | 54 |
|
50 |
| -1. On the next screen, you can choose to enable Microsoft.Graph or allow another API project to have access. You can configure this later if you don't have the information yet. |
| 55 | + :::image type="content" source="./media/vs-azure-active-directory/vs-2019/add-dependency-microsoft-identity-platform.png" border="false" alt-text="Screenshot showing the Microsoft identity platform option in Visual Studio."::: |
51 | 56 |
|
52 |
| -  |
| 57 | + :::moniker-end |
53 | 58 |
|
54 |
| -1. Choose **Next**. The **Summary of changes** screen appears showing what is being changed in the project. |
| 59 | + If your installation is missing the .NET MSIdentity tool, the **Required components** window opens with a message to complete the install: |
55 | 60 |
|
56 |
| -  |
| 61 | + :::image type="content" source="./media/vs-azure-active-directory/required-components.png" border="false" alt-text="Screenshot of the Required Components window with a message to install the .NET MSIdentity tool."::: |
57 | 62 |
|
58 |
| -1. The **Dependency configuration process** screen shows the specific changes that are being made to your project. |
| 63 | + As needed, follow the steps to install the .NET MSIdentity tool, and then continue with this procedure. |
59 | 64 |
|
60 |
| -Now the new service dependency shows on the Connected Services screen. |
| 65 | +1. The **Microsoft identity platform** configuration screen opens. |
61 | 66 |
|
62 |
| - |
63 |
| - |
64 |
| -If you want to modify it, such as to add support for an API such as Microsoft.Graph, click on the three dots, and then choose **Edit dependency**. You can repeat the steps and choose the APIs that you want to grant access to. |
65 |
| - |
66 |
| -You can also see the Active Directory domain on the [Azure portal](https://go.microsoft.com/fwlink/p/?LinkID=525040). |
67 |
| - |
68 |
| -:::moniker-end |
69 |
| -:::moniker range="<=vs-2019" |
70 |
| -1. In Visual Studio, create or open an ASP.NET MVC project, or an ASP.NET Web API project. |
| 67 | + As needed, sign in to Azure. After you sign in, you see a list of your applications for the selected **Tenant**: |
71 | 68 |
|
72 |
| -1. Select the **Project**, **Manage Connected Services** menu command, or right-click the **Connected Services** node found under the project in Solution Explorer, and choose **Manage Connected Services**, and then select the link **Add a service dependency** and choose **Microsoft Identity platform**. |
| 69 | + :::image type="content" source="./media/vs-azure-active-directory/owned-applications.png" border="false" alt-text="Screenshot showing the list of owned applications."::: |
73 | 70 |
|
74 |
| -  |
| 71 | + If you don't have an application, select **Create new**: |
| 72 | + |
| 73 | + 1. For Microsoft Entra ID, select **Microsoft** as the tenant. |
| 74 | + |
| 75 | + 1. Enter the display name for the new application. |
| 76 | + |
| 77 | + 1. Select **Register**: |
75 | 78 |
|
76 |
| - If you are missing the .NET MSIdentity tool, the screen prompts you to install it. |
| 79 | + :::image type="content" source="./media/vs-azure-active-directory/register-an-application.png" border="false" alt-text="Screenshot showing how to register a new application."::: |
77 | 80 |
|
78 |
| -  |
| 81 | + After the new application registers, it appears in the application list. |
| 82 | + |
| 83 | +1. In the application list, select the application to use, and select **Next**. |
79 | 84 |
|
80 |
| - If you had to install the tool, you might need to restart the process again from step 1. |
| 85 | + <a name="update-service-settings"> </a> |
| 86 | + |
| 87 | +1. On the **Additional settings** screen, choose your preferred settings. You can enable Microsoft Graph or allow another API project to have access. You can also configure these settings later. |
81 | 88 |
|
82 |
| -1. The **Configure Microsoft identity platform** screen appears. If you haven't signed in to Azure, you're asked to sign in. Once you're signed in, you see a list of your applications. |
| 89 | + :::image type="content" source="./media/vs-azure-active-directory/additional-settings.png" border="false" alt-text="Screenshot of additional options for the application, including enable Microsoft Graph and allow API access."::: |
83 | 90 |
|
84 |
| -  |
| 91 | +1. Select **Next**. The **Summary of changes** screen appears for the project, including updates to dependencies to support Microsoft identity platform: |
85 | 92 |
|
86 |
| -1. If you don't have an application, choose **Create new**, and enter the application name. For Microsoft Entra ID, choose Microsoft as the tenant. |
| 93 | + :::image type="content" source="./media/vs-azure-active-directory/summary-of-changes.png" border="false" alt-text="Screenshot showing Summary of changes screen for the project."::: |
87 | 94 |
|
88 |
| -  |
| 95 | +1. Select **Finish**. The **Dependency configuration progress** screen shows the process status. When the process finishes successfully, the status shows the statement "Complete. Microsoft identity platform \<application> is configured." |
89 | 96 |
|
90 |
| - The application you entered now shows in the list. Select it and choose **Next**. |
| 97 | +1. Select **Close** to close the window. |
91 | 98 |
|
92 |
| -1. On the next screen, you can choose to enable Microsoft.Graph or allow another API project to have access. You can configure this later if you don't have the information yet. |
| 99 | +The new connection is listed under **Service Dependencies** in the **Connected Services** screen for the project: |
93 | 100 |
|
94 |
| -  |
| 101 | +:::image type="content" source="./media/vs-azure-active-directory/identity-platform-service-dependency.png" border="false" alt-text="Screenshot showing the Microsoft identity platform service dependency listed as a connected service for the project."::: |
95 | 102 |
|
96 |
| -1. Choose **Next**. The **Summary of changes** screen appears showing what is being changed in the project. |
| 103 | +You can also see the Microsoft Entra ID domain for the application connection in the [Azure portal](https://go.microsoft.com/fwlink/p/?LinkID=525040). |
97 | 104 |
|
98 |
| -  |
| 105 | +## Modify connected service settings |
99 | 106 |
|
100 |
| -1. The **Dependency configuration process** screen shows the specific changes that are being made to your project. |
| 107 | +After you add Microsoft identity platform as a connected service, you can modify the settings as needed: |
101 | 108 |
|
102 |
| -Now the new service dependency shows on the Connected Services screen. |
| 109 | +1. In the **Connected Services** > **Service Dependencies** screen, locate the **Microsoft identity platform** service. |
103 | 110 |
|
104 |
| - |
| 111 | +1. Select **More options** (**...**) for the service, and then select **Edit dependency**. |
105 | 112 |
|
106 |
| -If you want to modify it, such as to add support for an API such as Microsoft.Graph, click on the three dots, and then choose **Edit dependency**. You can repeat the steps and choose the APIs that you want to grant access to. |
| 113 | +1. Select the tenant that contains the application, select the application, and then select **Next**. |
107 | 114 |
|
108 |
| -You can also see the Active Directory domain on the [Azure portal](https://go.microsoft.com/fwlink/p/?LinkID=525040). |
109 |
| -:::moniker-end |
| 115 | +Follow the process described earlier to [modify and apply your preferred settings](#update-service-settings). Repeat the process as needed to grant project access for necessary APIs. |
110 | 116 |
|
111 | 117 | ## Related content
|
112 | 118 |
|
113 |
| -- [Authentication scenarios for Microsoft Entra ID](/azure/active-directory/develop/authentication-vs-authorization) |
114 |
| -- [Add sign-in with Microsoft to an ASP.NET web app](/azure/active-directory/develop/quickstart-v2-aspnet-webapp) |
| 119 | +- [Authentication scenarios for Microsoft Entra ID](/entra/identity-platform/authentication-vs-authorization) |
| 120 | +- [Add sign-in with Microsoft to an ASP.NET web app](/entra/identity-platform/quickstart-web-app-sign-in) |
0 commit comments