Integrating Azure Function with Dynamics 365

Blog
Spread the love
  1. Signup on azure portal and make sure to turn of E-mandate.https://portal.azure.com
  2. Creating an azure function in visual studio:
  1. Download visual studio 2019 or 2022
  2. After downloading visual studio install the azure development workload.
  3. img

  4. Once azure development workload is installed open create a new project in visual studio.
  5. img

  6. Now in search for template , search for azure function and select the azure function templates and click on next.
  7. img

  8. Now name your function and click on next.
  9. img

  10. Now From the dropdown select .Net 8.0 isolated(Long term support) or Azure v2.net core.
  11. img

  12. Now Select the http triggers from the dropdown, if you want to know more about
    the triggers Click this.
  13. img

  14. Now select the authorization level as function from the dropdown and then create, if you want to know more about authorization Click this.
  15. img

  16. Now after creating the project wait for few seconds for the creation of the project(Note: The errors will be removed automatically once the project is ready,wait for few seconds.)
  17. img

Publishing our Azure function to Azure Portal

  1. Before publishing the function to the portal check if it is running perfectly on localhost
  2. Once the project is created successfully press ctrl+f5 to run the project locally.
  3. After running the project a command terminal will open like this giving you the localhost url of the azure function.
  4. img

  5. Copy paste the url to check if it is running properly or not.
  6. img

  7. After this publish the azure function to the portal by right clicking on the function App.
  8. img

  9. After that click on publish.
  10. img

  11. Then select publish to Azure and click next.
  12. img

  13. After that select azure function for windows and click next.(NOTE: You will need to signup to your azure account if you have not done after this step).
  14. img

  15. After this if you have your pre made function instance select that or create a new one by clicking on create new.
  16. img

  17. Now a popup will open to create new function instance select the options as mentioned down and select create.
  18. img

  19. After this click on finish
  20. img

  21. After this publish the function App it will take some time to get published.
  22. img

  23. Now go to azure portal and check if it is published or not in resources section Click this.

Getting Client ID,secret Id and Tenant ID to connect dynamics 365 and azure function.

  1. Goto Azure portal and search for app registration and then go to app registration page and click on new registration.
  2. img

    img

  3. Now name your app and click on register.
  4. img

  5. After this click on certificates and secrets and then add new client secret.
  6. img

  7. Follow these steps.
  8. img

  9. Copy the value somewhere this is the client secret id that we will need.(Note: it is visible only for the first time copy it and store it for future use).
  10. img

  11. Now goto api permission and add a permission for dynamic crm.
  12. img

  13. Select dynamic crm.
  14. img

  15. Then allow user permission.
  16. img

  17. Then grant admin consent.
  18. img

  19. You will get you clientId and tenantId here.
  20. img

Registering our app in dynamics.

Follow below Steps.

  1. Goto Power admin center.
  2. Select settings.
  3. Then User permissions and then application user.

img

img

img

img

img

Done.

Now, we will create Azure Function to connect with the Dynamics 365 CRM we need to add the required NuGet Package [Microsoft.CrmSdk.CoreAssemblies]. To add the NuGet Package right-click on the Project and click on Manage Nuget packages.

img

img

img

img

Install both these packages.

Now add these lines of code for connecting dynamics365 and azure function and run this function as described earlier in the steps(Run on localhost) to see if it is fetching the details from dynamics 365 or not.

Connecting azure and dynamics using webhooks to trigger function base on operation performed on crm.

  1. Open xrm toolbox and connect it you your environment.
  2. Open Plugin registration tool and click on register then select add new webhook from the dropdown.
  3. img

    img

Add Name of your choice and the endpoint url that we will get from the azure portal follow these steps.

  1. Goto azure portal and select the resource which contains your function app.
  2. img

  3. Select the function that you published from visual code.
  4. img

  5. Select get function url
  6. img

  7. Copy the master url it have two parts one the endpoint url and one is code separate it.
  8. img

    Copy the url before the question mark

    https://tutorial220240811173932.azurewebsites.net/api/Function1

    Code:code=s6SVPfIBy6M2pQBNAMFeU4auOc4_IW75d7KDhpzdE1MfAzFuEo31hg%3D%3D

    Now paste the url in endpoint url in plugin tool and code in key (only paste the code after =signs6SVPfIBy6M2pQBNAMFeU4auOc4_IW75d7KDhpzdE1MfAzFuEo31hg%3D%3D).

    img

    Now click on save.

    Now register a new step on this webhook on which the url will be hit and the function will run.

bluethinkinc_blog

bluethinkinc_blog

2025-02-03

0

Leave a Reply

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

Find More Blogs

Enhancing Performance with Reactive Java: A Beginner-Friendly Guide

Spread the love In today’s fast-paced software

Integrating Azure Function with Dynamics 365

Spread the love Signup on azure portal and make sure to

How to Create a Power Apps Component Framework (PCF) with React

Spread the love If youʼve been looking to supercharge your

Customize lead qualification for a seamless experience

Spread the love When the 2024 Release Wave 2 was launched,

Create a Custom Console Command in Spryker

Spread the love In Spryker, developers can create custom

SALESFORCE

Spread the love Salesforce is a cloud-based software

CRUD Operation in Spryker Backoffice with a Custom Module

Spread the love Spryker is a highly flexible and modular

How to create custom module on Spryker for Backoffice?

Spread the love Creating a custom module in Spryker

How to Install Spryker Project with Docker on Local Machine

Spread the love Spryker is a flexible and scalable commerce

How to Add a Custom Tab to the Customer Order Detail Page in Magento 2

Spread the love Adding a custom tab to the Order Detail

bluethinkinc Blogs