web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Service-to-service authentication (Azure Function -> Dynamics CRM)

(0) ShareShare
ReportReport
Posted on by

Hi,

I thought I finally figured out OAuth authentication, but now it seems I am missing something in relation to Dynamics 365 CRM. Here is the scenario: A record change in Dynamics 365 CRM is sending a message to an Azure ServiceBus Queue. This triggers an Azure Function which should retrieve records from Dynamics 365 CRM - using the oData endpoint - for processing. 

As an Azure Function is a background process without an active user interaction, oAuth authentication needs to happen in the background. I figured to register the Azure Function as an app in Azure AD and use the ClientId (and secret) to access Dynamics CRM. But as Dynamics CRM only has Delegated Permissions (require a user context) and no Application Permissions this isn't going to work (as far as I understand).

The workaround is to provide a username and password (in the UserCredentials object) and perform authentication using these. This only requires the admin to consent the app for all users in Azure AD. This seems to work (using ADAL v2), but in ADAL v3 the option to supply username and password in UserCredentials is removed so this doesn't seem like a future proof solution.

Are there a (good) solution to make this work. I would like to use Azure Functions for all kinds of background and batch operations for CRM but the authentication is a problem. Is there a way to get the active credentials (clientId) from the logged in CRM user to the function app. Maybe by using an authenticated HTTP trigger on the functions app? How to get the credentials from a plugin to the functions app? And calling other function apps (which have storage queue triggers) to access these credentials. 

Any suggestions are welcome, or a way to convince Microsoft to add Application Permissions to Dynamics CRM.

Thanks in advance,

Arjan

P.S. CRM Data Export Service, Portals and Voice of the Customer seem to use service-to-service authentication without client credentials?!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Tim Dutcher Profile Picture
    2,100 on at

    Hi Arjan,

    Take a look at the following article: https://www.linkedin.com/pulse/dynamics-365-setup-server-to-server-s2s-azure-ad-application-liu/

    Using the approach Winston described in the article, I have several Azure Functions interacting with Dynamics 365 CE Online.

    Are your requirements met by this approach?  If not, what are you needing to do that's different?

    -Tim

  • Community Member Profile Picture
    on at

    Thanks for the quick response. Been looking all day on how to register an App with CRM. Nowhere to be found in the Microsoft documentation. This was exactly what I was looking for.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans