Online Management API: Using Console Application

Once you have set up the App Permissions for Azure AD to access Dynamics CRM Online you can use the Application ID to authenticate with Online Management API and work with Various Operations.


Follow the given steps to understand how to set up Console Application to work with Online Management API:

  • Open Visual Studio and Create a new “Console Application”
  • Create a New Class file called “Helper.cs” and copy the helper code (from SDK) to the file.


  • In Helper code update client id to your Application ID while you registered CRM Online App with Azure AD. Set URL to “http://localhost/” 
  • Add Reference to “Microsoft.IdentityModel.Clients.ActiveDirectory”. If you don’t have it installed you can install it through NuGet Package
    • Right click the References -> Click Manage NuGet Packages.
    • Search for “Microsoft.IdentityModel.Clients.ActiveDirectory” and select version “2.x.x” as version “3.x.x” will not work.  Click Install.
  • Replace Program class with following code (taken from SDK Sample) and add missing references.


  • Update the Service URL based on your region.
  • Run the Application, it will ask for Online Authentication and approval to give permissions to app.
  • Once executed you will get instance information.

For Sample Highlighted above you can refer to First Sample solution in following Git Repo.   

Leave a Reply

Your email address will not be published. Required fields are marked *