page_type | products | languages | extensions | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
|
This console application demonstrates how to make Delta Query calls to the Graph API, allowing applications to request only changed data from Microsoft Graph tenants.
The sample uses demonstates how graph calls can be made with the Graph SDK and how the reponses can be handled.
The specific example used in this sample involves monitoring changes(addition and removal) of MailFolders in an individual's email account.
To run this sample you will need:
- Visual Studio 2017
- An Internet connection
- An Azure Active Directory (Azure AD) tenant. For more information on how to get an Azure AD tenant, please see How to get an Azure AD tenant
From your shell or command line:
git clone https://github.com/microsoftgraph/ConsoleApp-DeltaQuery-DotNet
There is one project in this sample. To register it, you can:
- either follow the steps Step 2: Register the sample with your Azure Active Directory tenant and Step 3: Configure the sample to use your Azure AD tenant
- or use PowerShell scripts that:
- automatically creates the Azure AD applications and related objects (passwords, permissions, dependencies) for you
- modify the Visual Studio projects' configuration files.
If you want to use this automation:
-
On Windows run PowerShell and navigate to the root of the cloned directory
-
In PowerShell run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
-
Run the script to create your Azure AD application and configure the code of the sample application accordinly.
.\AppCreationScripts\Configure.ps1
Other ways of running the scripts are described in App Creation Scripts
-
Open the Visual Studio solution and click start
If you don't want to use this automation, follow the steps below
As a first step you'll need to:
- Sign in to the Azure portal using either a work or school account or a personal Microsoft account.
- If your account gives you access to more than one tenant, select your account in the top right corner, and set your portal session to the desired Azure AD tenant (using Switch Directory).
- In the left-hand navigation pane, select the Azure Active Directory service, and then select App registrations (Preview).
- In App registrations (Preview) page, select Register an Application.
- When the Register an application page appears, enter your application's registration information:
- In the Name section, enter a meaningful application name that will be displayed to users of the app, for example
ConsoleApp-DeltaQuery-DotNet
. - In the Supported account types section, select Accounts in any organizational directory and personal Microsoft accounts (e.g. Skype, Xbox, Outlook.com).
- Select Register to create the application.
- In the Name section, enter a meaningful application name that will be displayed to users of the app, for example
- On the app Overview page, find the Application (client) ID value and record it for later. You'll need it to configure the Visual Studio configuration file for this project.
- In the list of pages for the app, select Authentication
- In the Suggested Redirect URIs for public clients(mobile,desktop), check the second box so that the app can work with the MSAL libs used in the application. (The box should contain the option urn:ietf:wg:oauth:2.0:oob).
- In the list of pages for the app, select API permissions
- Click the Add a permission button and then,
- Ensure that the Microsoft APIs tab is selected
- In the Commonly used Microsoft APIs section, click on Microsoft Graph
- In the Delegated permissions section, ensure that the right permissions are checked: Mail.Read. Use the search box if necessary.
- Select the Add permissions button
In the steps below, "ClientID" is the same as "Application ID" or "AppId".
Open the solution in Visual Studio to configure the projects
- In the ConsoleApplication folder, rename the
appsettings.json.example
file toappsettings.json
- Open and edit the
appsettings.json
file to make the following change- Find the line where
ClientId
is set asYOUR_CLIENT_ID_HERE
and replace the existing value with the application ID (clientId) of theConsoleApp-DeltaQuery-DotNet
application copied from the Azure portal.
- Find the line where
Clean the solution, rebuild the solution, and start it in the debugger.
If you'd like to contribute to this sample, see CONTRIBUTING.MD.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
We'd love to get your feedback about the Microsoft Graph Webhooks sample using WebJobs SDK. You can send your questions and suggestions to us in the Issues section of this repository.
Questions about Microsoft Graph in general should be posted to Stack Overflow. Make sure that your questions or comments are tagged with [MicrosoftGraph].
If you have a feature suggestion, please post your idea on our User Voice page, and vote for your suggestions there.
- AAD DQ sample
- Working with Delta Query in Microsoft Graph
- Microsoft Graph developer site
- Call Microsoft Graph in an ASP.NET MVC app
- MSAL.NET
Copyright (c) 2019 Microsoft Corporation. All rights reserved.