Git Product home page Git Product logo

consoleapp-deltaquery-dotnet-sample's Introduction

page_type products languages extensions
sample
ms-graph
csharp
contentType technologies createdDate
samples
Microsoft Graph
5/25/2017 5:03:53 PM

Microsoft Graph delta query sample

This console application demonstrates how to make delta queries to Microsoft Graph, allowing applications to request only changed entities within a target resource. This sample monitors changes to the mail folders in a user's mailbox.

How To Run This Sample

To run this sample you will need:

  • The .NET Core 3.1 SDK
  • A user in a Microsoft 365 tenant with an Exchange Online mailbox.

Step 1: Register the sample application in Azure Active Directory

Before running the sample, you will need to create an app registration in Azure Active Directory to obtain an application ID. You can do this with the PowerShell script in this sample, or you can register it manually in the Azure Active Directory portal.

Option 1: Register with PowerShell

The RegisterApp.ps1 script uses the Azure AD PowerShell for Graph module to create the app registration.

  1. Open Windows PowerShell in the root directory of this sample.

  2. If you do not have the Azure AD PowerShell module installed, run the following command to install it:

    Install-Module AzureAD
  3. Run the following command to set the execution policy for the current PowerShell window to allow the script to run.

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
  4. Run the script with the following command.

    ./RegisterApp.ps1
  5. In the pop-up window, sign in using a Microsoft 365 user that has permission to register an application in Azure Active Directory.

  6. The application ID is printed to the console.

    App creation successful. Your app ID is: b730d25e-c81c-4046-a49c-ac56c07e930a

Option 2: Register with the Azure Active Directory admin center

  1. Open a browser and navigate to the Azure Active Directory admin center and login using a Microsoft 365 user that has permission to register an application in Azure Active Directory.

  2. Select Azure Active Directory in the left-hand navigation, then select App registrations under Manage.

    A screenshot of the App registrations

  3. Select New registration. On the Register an application page, set the values as follows.

    • Set Name to Delta Query Console Sample.
    • Set Supported account types to Accounts in any organizational directory and personal Microsoft accounts.
    • Leave Redirect URI empty.

    A screenshot of the Register an application page

  4. Select Register. On the Delta Query Console Sample page, copy the value of the Application (client) ID and save it, you will need it in the next step.

    A screenshot of the application ID of the new app registration

  5. Select the Add a Redirect URI link. On the Redirect URIs page, locate the Suggested Redirect URIs for public clients (mobile, desktop) section. Select the https://login.microsoftonline.com/common/oauth2/nativeclient URI.

    A screenshot of the Redirect URIs page

  6. Locate the Default client type section and change the Treat application as a public client toggle to Yes, then choose Save.

    A screenshot of the Default client type section

Step 2: Configure the sample

  1. Open your command-line interface (CLI) in the directory that contains DeltaQuery.csproj.

  2. Run the following command.

    dotnet user-secrets init
  3. Run the following command to store your application ID (obtained in the previous step) to the secret manager Be sure to replace YOUR_APP_ID with your application ID.

    dotnet user-secrets set AzureAppId YOUR_APP_ID

Step 3: Run the sample

When the sample runs, it will prompt you to browse to a login URL and enter a device code. Once signed in, the app will check for changes to the mail folders in the user's mailbox every 30 seconds.

Option 1: Using Visual Studio Code

  1. Open the root folder of this sample using Visual Studio Code.

  2. On the Debug menu, choose Start Debugging.

Option 2: From the command line

  1. Open your command-line interface (CLI) in the directory that contains DeltaQuery.csproj.

  2. Run the following command to build the sample.

    dotnet build
  3. Run the following command to run the sample.

    dotnet run

Contributing

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.

Copyright (c) 2020 Microsoft Corporation. All rights reserved.

consoleapp-deltaquery-dotnet-sample's People

Contributors

andrueastman avatar darrelmiller avatar jasonjoh avatar madhumitadange avatar nokafor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.