Skip to content

Commit 11b1927

Browse files
Python and ASP.NET Core daemon quickstarts
1 parent 2cb2a27 commit 11b1927

File tree

2 files changed

+36
-192
lines changed

2 files changed

+36
-192
lines changed

articles/active-directory/develop/quickstart-v2-netcore-daemon.md

Lines changed: 21 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -20,117 +20,43 @@ ms.custom: devx-track-csharp, aaddev, identityplatformtop40, "scenarios:getting-
2020

2121
In this quickstart, you download and run a code sample that demonstrates how a .NET Core console application can get an access token to call the Microsoft Graph API and display a [list of users](/graph/api/user-list) in the directory. The code sample also demonstrates how a job or a Windows service can run with an application identity, instead of a user's identity. The sample console application in this quickstart is also a daemon application, so it's a confidential client application.
2222

23-
> [!div renderon="docs"]
24-
> The following diagram shows how the sample app works:
25-
>
26-
> ![Diagram that shows how the sample app generated by this quickstart works.](media/quickstart-v2-netcore-daemon/netcore-daemon-intro.svg)
27-
>
28-
2923
## Prerequisites
3024

3125
This quickstart requires [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download) but will also work with .NET 5.0 SDK.
3226

33-
> [!div renderon="docs"]
34-
> ## Register and download the app
35-
36-
> [!div renderon="docs" class="sxs-lookup"]
37-
>
38-
> You have two options to start building your application: automatic or manual configuration.
39-
>
40-
> ### Automatic configuration
41-
>
42-
> If you want to register and automatically configure your app and then download the code sample, follow these steps:
43-
>
44-
> 1. Go to the <a href="https://portal.azure.com/?Microsoft_AAD_RegisteredApps=true#blade/Microsoft_AAD_RegisteredApps/applicationsListBlade/quickStartType/DotNetCoreDaemonQuickstartPage/sourceType/docs" target="_blank">Azure portal page for app registration</a>.
45-
> 1. Enter a name for your application and select **Register**.
46-
> 1. Follow the instructions to download and automatically configure your new application in one click.
47-
>
48-
> ### Manual configuration
49-
>
50-
> If you want to manually configure your application and code sample, use the following procedures.
51-
>
52-
> [!div renderon="docs"]
53-
> #### Step 1: Register your application
54-
> To register your application and add the app's registration information to your solution manually, follow these steps:
55-
>
56-
> 1. Sign in to the <a href="https://portal.azure.com/" target="_blank">Azure portal</span></a>.
57-
> 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.
58-
> 1. Search for and select **Azure Active Directory**.
59-
> 1. Under **Manage**, select **App registrations** > **New registration**.
60-
> 1. For **Name**, enter a name for your application. For example, enter **Daemon-console**. Users of your app will see this name, and you can change it later.
61-
> 1. Select **Register** to create the application.
62-
> 1. Under **Manage**, select **Certificates & secrets**.
63-
> 1. Under **Client secrets**, select **New client secret**, enter a name, and then select **Add**. Record the secret value in a safe location for use in a later step.
64-
> 1. Under **Manage**, select **API Permissions** > **Add a permission**. Select **Microsoft Graph**.
65-
> 1. Select **Application permissions**.
66-
> 1. Under the **User** node, select **User.Read.All**, and then select **Add permissions**.
67-
68-
> [!div class="sxs-lookup" renderon="portal"]
69-
> ### Download and configure your quickstart app
70-
>
71-
> #### Step 1: Configure your application in the Azure portal
72-
> For the code sample in this quickstart to work, create a client secret and add the Graph API's **User.Read.All** application permission.
73-
> > [!div renderon="portal" id="makechanges" class="nextstepaction"]
74-
> > [Make these changes for me]()
75-
>
76-
> > [!div id="appconfigured" class="alert alert-info"]
77-
> > ![Already configured](media/quickstart-v2-netcore-daemon/green-check.png) Your application is configured with these attributes.
27+
> [!div class="sxs-lookup"]
28+
### Download and configure your quickstart app
7829

79-
#### Step 2: Download your Visual Studio project
30+
#### Step 1: Configure your application in the Azure portal
31+
For the code sample in this quickstart to work, create a client secret and add the Graph API's **User.Read.All** application permission.
32+
> [!div class="nextstepaction"]
33+
> [Make these changes for me]()
8034
81-
> [!div renderon="docs"]
82-
> [Download the Visual Studio project](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/archive/master.zip)
83-
>
84-
> You can run the provided project in either Visual Studio or Visual Studio for Mac.
35+
> [!div class="alert alert-info"]
36+
> ![Already configured](media/quickstart-v2-netcore-daemon/green-check.png) Your application is configured with these attributes.
8537
38+
#### Step 2: Download your Visual Studio project
8639

87-
> [!div class="sxs-lookup" renderon="portal"]
40+
> [!div class="sxs-lookup"]
8841
> Run the project by using Visual Studio 2019.
89-
> [!div class="sxs-lookup" renderon="portal" id="autoupdate" class="nextstepaction"]
42+
> [!div class="sxs-lookup" id="autoupdate" class="nextstepaction"]
9043
> [Download the code sample](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/archive/master.zip)
9144
9245
[!INCLUDE [active-directory-develop-path-length-tip](../../../includes/active-directory-develop-path-length-tip.md)]
9346

94-
> [!div class="sxs-lookup" renderon="portal"]
47+
> [!div class="sxs-lookup"]
9548
> > [!NOTE]
9649
> > `Enter_the_Supported_Account_Info_Here`
9750
98-
> [!div renderon="docs"]
99-
> #### Step 3: Configure your Visual Studio project
100-
>
101-
> 1. Extract the .zip file to a local folder that's close to the root of the disk. For example, extract to *C:\Azure-Samples*.
102-
>
103-
> We recommend extracting the archive into a directory near the root of your drive to avoid errors caused by path length limitations on Windows.
104-
>
105-
> 1. Open the solution in Visual Studio: *1-Call-MSGraph\daemon-console.sln* (optional).
106-
> 1. In *appsettings.json*, replace the values of `Tenant`, `ClientId`, and `ClientSecret`:
107-
>
108-
> ```json
109-
> "Tenant": "Enter_the_Tenant_Id_Here",
110-
> "ClientId": "Enter_the_Application_Id_Here",
111-
> "ClientSecret": "Enter_the_Client_Secret_Here"
112-
> ```
113-
> In that code:
114-
> - `Enter_the_Application_Id_Here` is the application (client) ID for the application that you registered.
115-
To find the values for the application (client) ID and the directory (tenant) ID, go to the app's **Overview** page in the Azure portal.
116-
> - Replace `Enter_the_Tenant_Id_Here` with the tenant ID or tenant name (for example, `contoso.microsoft.com`).
117-
> - Replace `Enter_the_Client_Secret_Here` with the client secret that you created in step 1.
118-
To generate a new key, go to the **Certificates & secrets** page.
119-
120-
> [!div class="sxs-lookup" renderon="portal"]
121-
> #### Step 3: Admin consent
122-
123-
> [!div renderon="docs"]
124-
> #### Step 4: Admin consent
51+
> [!div class="sxs-lookup"]
52+
53+
#### Step 3: Admin consent
12554

12655
If you try to run the application at this point, you'll receive an *HTTP 403 - Forbidden* error: "Insufficient privileges to complete the operation." This error happens because any app-only permission requires a global administrator of your directory to give consent to your application. Select one of the following options, depending on your role.
12756

12857
##### Global tenant administrator
12958

130-
> [!div renderon="docs"]
131-
> If you're a global tenant administrator, go to **Enterprise applications** in the Azure portal. Select your 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 your directory).
132-
133-
> [!div renderon="portal" class="sxs-lookup"]
59+
> [!div class="sxs-lookup"]
13460
> If you're a global administrator, go to the **API Permissions** page and select **Grant admin consent for Enter_the_Tenant_Name_Here**.
13561
> > [!div id="apipermissionspage"]
13662
> > [Go to the API Permissions page]()
@@ -143,18 +69,9 @@ If you're a standard user of your tenant, ask a global administrator to grant ad
14369
https://login.microsoftonline.com/Enter_the_Tenant_Id_Here/adminconsent?client_id=Enter_the_Application_Id_Here
14470
```
14571

146-
> [!div renderon="docs"]
147-
> In that URL:
148-
> * Replace `Enter_the_Tenant_Id_Here` with the tenant ID or tenant name (for example, `contoso.microsoft.com`).
149-
> * `Enter_the_Application_Id_Here` is the application (client) ID for the application that you registered.
150-
15172
You might see the error "AADSTS50011: No reply address is registered for the application" after you grant consent to the app by using the preceding URL. This error happens because this application and the URL don't have a redirect URI. You can ignore it.
15273

153-
> [!div class="sxs-lookup" renderon="portal"]
154-
> #### Step 4: Run the application
155-
156-
> [!div renderon="docs"]
157-
> #### Step 5: Run the application
74+
#### Step 4: Run the application
15875

15976
If you're using Visual Studio or Visual Studio for Mac, press **F5** to run the application. Otherwise, run the application via command prompt, console, or terminal:
16077

@@ -172,10 +89,10 @@ This quickstart application uses a client secret to identify itself as a confide
17289
## More information
17390
This section gives an overview of the code required to sign in users. This overview can be useful to understand how the code works, what the main arguments are, and how to add sign-in to an existing .NET Core console application.
17491

175-
> [!div class="sxs-lookup" renderon="portal"]
176-
> ### How the sample works
177-
>
178-
> ![Diagram that shows how the sample app generated by this quickstart works.](media/quickstart-v2-netcore-daemon/netcore-daemon-intro.svg)
92+
> [!div class="sxs-lookup"]
93+
### How the sample works
94+
95+
![Diagram that shows how the sample app generated by this quickstart works.](media/quickstart-v2-netcore-daemon/netcore-daemon-intro.svg)
17996

18097
### MSAL.NET
18198

articles/active-directory/develop/quickstart-v2-python-daemon.md

Lines changed: 15 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -19,105 +19,40 @@ ms.custom: aaddev, identityplatformtop40, devx-track-python, "scenarios:getting-
1919

2020
In this quickstart, you download and run a code sample that demonstrates how a Python application can get an access token using the app's identity to call the Microsoft Graph API and display a [list of users](/graph/api/user-list) in the directory. The code sample demonstrates how an unattended job or Windows service can run with an application identity, instead of a user's identity.
2121

22-
> [!div renderon="docs"]
23-
> ![Shows how the sample app generated by this quickstart works](media/quickstart-v2-python-daemon/python-console-daemon.svg)
24-
2522
## Prerequisites
2623

2724
To run this sample, you need:
2825

2926
- [Python 2.7+](https://www.python.org/downloads/release/python-2713) or [Python 3+](https://www.python.org/downloads/release/python-364/)
3027
- [MSAL Python](https://github.com/AzureAD/microsoft-authentication-library-for-python)
3128

32-
> [!div renderon="docs"]
33-
> ## Register and download your quickstart app
34-
35-
> [!div renderon="docs" class="sxs-lookup"]
36-
>
37-
> You have two options to start your quickstart application: Express (Option 1 below), and Manual (Option 2)
38-
>
39-
> ### Option 1: Register and auto configure your app and then download your code sample
40-
>
41-
> 1. Go to the <a href="https://portal.azure.com/?Microsoft_AAD_RegisteredApps=true#blade/Microsoft_AAD_RegisteredApps/applicationsListBlade/quickStartType/PythonDaemonQuickstartPage/sourceType/docs" target="_blank">Azure portal - App registrations</a> quickstart experience.
42-
> 1. Enter a name for your application and select **Register**.
43-
> 1. Follow the instructions to download and automatically configure your new application with just one click.
44-
>
45-
> ### Option 2: Register and manually configure your application and code sample
46-
47-
> [!div renderon="docs"]
48-
> #### Step 1: Register your application
49-
> To register your application and add the app's registration information to your solution manually, follow these steps:
50-
>
51-
> 1. Sign in to the <a href="https://portal.azure.com/" target="_blank">Azure portal</a>.
52-
> 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.
53-
> 1. Search for and select **Azure Active Directory**.
54-
> 1. Under **Manage**, select **App registrations** > **New registration**.
55-
> 1. Enter a **Name** for your application, for example `Daemon-console`. Users of your app might see this name, and you can change it later.
56-
> 1. Select **Register**.
57-
> 1. Under **Manage**, select **Certificates & secrets**.
58-
> 1. Under **Client secrets**, select **New client secret**, enter a name, and then select **Add**. Record the secret value in a safe location for use in a later step.
59-
> 1. Under **Manage**, select **API Permissions** > **Add a permission**. Select **Microsoft Graph**.
60-
> 1. Select **Application permissions**.
61-
> 1. Under **User** node, select **User.Read.All**, then select **Add permissions**.
62-
63-
> [!div class="sxs-lookup" renderon="portal"]
64-
> ### Download and configure the quickstart app
65-
>
66-
> #### Step 1: Configure your application in Azure portal
67-
> For the code sample in this quickstart to work, create a client secret and add Graph API's **User.Read.All** application permission.
68-
> > [!div renderon="portal" id="makechanges" class="nextstepaction"]
69-
> > [Make these changes for me]()
70-
>
71-
> > [!div id="appconfigured" class="alert alert-info"]
72-
> > ![Already configured](media/quickstart-v2-netcore-daemon/green-check.png) Your application is configured with these attributes.
29+
> [!div class="sxs-lookup"]
30+
### Download and configure the quickstart app
7331

74-
#### Step 2: Download the Python project
32+
#### Step 1: Configure your application in Azure portal
33+
For the code sample in this quickstart to work, create a client secret and add Graph API's **User.Read.All** application permission.
34+
> [!div class="nextstepaction"]
35+
> [Make these changes for me]()
7536
76-
> [!div renderon="docs"]
77-
> [Download the Python daemon project](https://github.com/Azure-Samples/ms-identity-python-daemon/archive/master.zip)
37+
> [!div class="alert alert-info"]
38+
> ![Already configured](media/quickstart-v2-netcore-daemon/green-check.png) Your application is configured with these attributes.
39+
40+
#### Step 2: Download the Python project
7841

79-
> [!div renderon="portal" id="autoupdate" class="sxs-lookup nextstepaction"]
42+
> [!div class="sxs-lookup nextstepaction"]
8043
> [Download the code sample](https://github.com/Azure-Samples/ms-identity-python-daemon/archive/master.zip)
8144
82-
> [!div class="sxs-lookup" renderon="portal"]
45+
> [!div class="sxs-lookup"]
8346
> > [!NOTE]
8447
> > `Enter_the_Supported_Account_Info_Here`
8548
86-
87-
> [!div renderon="docs"]
88-
> #### Step 3: Configure the Python project
89-
>
90-
> 1. Extract the zip file to a local folder close to the root of the disk, for example, **C:\Azure-Samples**.
91-
> 1. Navigate to the sub folder **1-Call-MsGraph-WithSecret**.
92-
> 1. Edit **parameters.json** and replace the values of the fields `authority`, `client_id`, and `secret` with the following snippet:
93-
>
94-
> ```json
95-
> "authority": "https://login.microsoftonline.com/Enter_the_Tenant_Id_Here",
96-
> "client_id": "Enter_the_Application_Id_Here",
97-
> "secret": "Enter_the_Client_Secret_Here"
98-
> ```
99-
> Where:
100-
> - `Enter_the_Application_Id_Here` - is the **Application (client) ID** for the application you registered.
101-
> - `Enter_the_Tenant_Id_Here` - replace this value with the **Tenant Id** or **Tenant name** (for example, contoso.microsoft.com)
102-
> - `Enter_the_Client_Secret_Here` - replace this value with the client secret created on step 1.
103-
>
104-
> > [!TIP]
105-
> > To find the values of **Application (client) ID**, **Directory (tenant) ID**, go to the app's **Overview** page in the Azure portal. To generate a new key, go to **Certificates & secrets** page.
106-
107-
> [!div class="sxs-lookup" renderon="portal"]
108-
> #### Step 3: Admin consent
109-
110-
> [!div renderon="docs"]
111-
> #### Step 4: Admin consent
49+
#### Step 3: Admin consent
11250

11351
If you try to run the application at this point, you'll receive *HTTP 403 - Forbidden* error: `Insufficient privileges to complete the operation`. This error happens because any *app-only permission* requires Admin consent: a global administrator of your directory must give consent to your application. Select one of the options below depending on your role:
11452

11553
##### Global tenant administrator
11654

117-
> [!div renderon="docs"]
118-
> If you are a global tenant administrator, go to **API Permissions** page in **App registrations** in the Azure portal and select **Grant admin consent for {Tenant Name}** (Where {Tenant Name} is the name of your directory).
119-
120-
> [!div renderon="portal" class="sxs-lookup"]
55+
> [!div class="sxs-lookup"]
12156
> If you are a global administrator, go to **API Permissions** page select **Grant admin consent for Enter_the_Tenant_Name_Here**.
12257
> > [!div id="apipermissionspage"]
12358
> > [Go to the API Permissions page]()
@@ -130,17 +65,9 @@ If you're a standard user of your tenant, ask a global administrator to grant ad
13065
https://login.microsoftonline.com/Enter_the_Tenant_Id_Here/adminconsent?client_id=Enter_the_Application_Id_Here
13166
```
13267

133-
> [!div renderon="docs"]
134-
>> Where:
135-
>> * `Enter_the_Tenant_Id_Here` - replace this value with the **Tenant Id** or **Tenant name** (for example, contoso.microsoft.com)
136-
>> * `Enter_the_Application_Id_Here` - is the **Application (client) ID** for the application you registered.
137-
138-
> [!div class="sxs-lookup" renderon="portal"]
68+
> [!div class="sxs-lookup"]
13969
> #### Step 4: Run the application
14070
141-
> [!div renderon="docs"]
142-
> #### Step 5: Run the application
143-
14471
You'll need to install the dependencies of this sample once.
14572

14673
```console

0 commit comments

Comments
 (0)