Configure Azure and create dynamics 365 apps using OAuth, WebAPI (C#)

Hey Everyone

This blog covers the configuration steps that are required for app registration in Azure console and then consume WebAPI for creating and search existing records in CRM.

Prerequisites :

  1. Using Azure Management Console
  2. Json Serialize using Newtonsoft
  3. Basic understanding of HttpClient and WebAPI in general
  4. ADAL (Azure Active Directory Authentication Library)

CONFIGURE YOUR APPLICATION USING AZURE MANAGEMENT CONSOLE:

  1. Sign-up for Azure Trial/Office 365/Dynamics 365 (Formerly called as CRM Online) in a single tenant.
  2. Launch your Azure Management Console and Navigate to Active Directory.
  3. main-ad-screen
  4. Register your application in Azure AD
  5. app-type-selectiontell-us-about-your-app
  6. Choose Native Client Application. You can read more about this in Azure Documentation.
  7. Once you've provided the information including Redirect Url. You should see the app dashboard as below
  8. azure-app-dash
  9. You've completed configuration! :)

 

USING CONSOLE APPLICATION TO START YOUR VISUAL STUDIO PROJECT

//Retrieve Authentication Token from Azure obtainauthtoken

You will need to pass your ClientId and RedirectUrl from the azure management console. Step 7 shows the clientID which is hidden. That would 32 digit GUID. Here's the flow how OAUTH works. Read more on this post.

To learn more about recording records in CRM see this post. If you'd like to understand the troubleshooting part with this sample, please read this post.

Hope you've had fun reading this. Happy WebAPI'ng :)

Thanks

Apurv