Setting up Billing Policy for Dataverse Environments in Power Platform for Azure Pay-As-You-Go plan | Microsoft Azure

Pay-as-you-go has been recently announced with Azure and I too wanted to explore this topic myself on my trials Dataverse/D365 Sales environment as well as my Microsoft Azure trial subscription which I started.

Disclaimer: Please note that I’m exploring this topic and sharing as I go on. Hence, I’ll continue to write further topics as I proceed. Please try on your Dataverse trial & Microsoft Azure trial subscription to identify / estimate the costs your actual implementation will incur.

I also recommend going through the below Microsoft Learn Pages for detailed information on pricing and meters of the Pay-as-you-go model –

Detailed Microsoft Docs for Pay-as-you-go: https://learn.microsoft.com/en-us/power-platform/admin/pay-as-you-go-overview?WT.mc_id=DX-MVP-5003911

Power Apps Pricing: https://powerapps.microsoft.com/en-us/pricing/

Pay-as-you-go Meters: https://learn.microsoft.com/en-us/power-platform/admin/pay-as-you-go-meters?tabs=image?WT.mc_id=DX-MVP-5003911

Let’s see how we can get started!

Setting up Billing Policy

Here’s how you create Billing Policy in Power Platform –

  1. In Power Platform Admin Center (https://admin.powerplatform.microsoft.com/), you can see Policies section. If you expand the same, you can see Billing Policies.

  2. Here, you can start by creating a new Billing Policy

  3. You can give it an appropriate name. And it doesn’t allow you to have spaces.

  4. Next, you’ll be asked to select the Subscription you wan to assign the Billing Policy under.
    Notice the error below. My Free Trial Azure Subscription doesn’t have a Resource Group created yet. Hence, this need to be present.


  5. Since at this point, I don’t have a Resource Group under the Azure Subscription I selected, I need to go to Azure Portal (https://portal.azure.com/), search for Resource Groups

  6. Since you might not have any Resource Group right away, you can create one.


  7. I’ll just give it a name which I can identify with.


  8. I’ll validate and Create the same in Azure.


  9. Resource Group will be created here.


  10. Now, when I come back to Power Platform, if I reselect the Azure Subscription, I’ll now see that the Resource Group I created is showing up.

  11. I’ll select the same and select United States as the Region.
    And click on Next.


  12. In the next steps, I can select which all Environments should be included in the Policy. Then, I can click on + Add to policy.

  13. You can see the Added to policy tab now showing your environment. Once you are satisfied with the selection, you can click on Next.

  14. Final step is to now Review and confirm the policy you are creating.

  15. It’ll take a moment to start provisioning. Then, you’ll see the status as Provisioning.

  16. Once completed, the status will show as Enabled.


  17. Now, when you go back to Azure Portal and open the Resource Group, you’ll find a Deployment show up



  18. Open it up and you’ll see a Deployment created.

  19. And if you open the Deployment, you can see the DataverseBilling which we had set up in Power Platform.


  20. And this point, you are now setup with using Pay-As-you-go plan for your Dataverse environment(s).

    Note: Further, I’ll write follow up posts as I explore Pay-as-you-go scenarios and experience myself.

Hope this helps!

Here are some Power Automate posts you want to check out –

  1. Select the item based on a key value using Filter Array in Power Automate
  2. Select values from an array using Select action in a Power Automate Flow
  3. Blocking Attachment Extensions in Dynamics 365 CRM
  4. Upgrade Dataverse for Teams Environment to Dataverse Environment
  5. Showing Sandbox or Non Production Apps in Power App mobile app
  6. Create a Power Apps Per User Plan Trial | Dataverse environment
  7. Install On-Premise Gateway from Power Automate or Power Apps | Power Platform
  8. Co-presence in Power Automate | Multiple users working on a Flow
  9. Search Rows (preview) Action in Dataverse connector in a Flow | Power Automate
  10. Suppress Workflow Header Information while sending back HTTP Response in a Flow | Power Automate
  11. Call a Flow from Canvas Power App and get back response | Power Platform\
  12. FetchXML Aggregation in a Flow using CDS (Current Environment) connector | Power Automate
  13. Parsing Outputs of a List Rows action using Parse JSON in a Flow | Common Data Service (CE) connector
  14. Asynchronous HTTP Response from a Flow | Power Automate
  15. Validate JSON Schema for HTTP Request trigger in a Flow and send Response | Power Automate
  16. Converting JSON to XML and XML to JSON in a Flow | Power Automate

Thank you!

Skip requirement to enter authentication method in M365 Login | Turn off Security Defaults

If you newly created a an M365 tenant, this is what you’ll be forced to by to enter authentication methods in this Security Defaults feature –

In most cases, even clicking on Skip for now option doesn’t help and I’m forced to enter an alternate authentication method.
Ideally, for Production purposes, you should keep this turned on. Only if you are on a trial and the tenant you are working on is for learning purposes, it is OK to turn this off.

Turn Off Security Defaults in Azure Portal

Here’s how you can turn off the Security Defaults requirement from the Azure Portal –

  1. Navigate to Azure Portal (https://portal.azure.com)

  2. Again, you’ll see this message so you can choose to skip this since we want to disable the Security Defaults.

  3. Then, go to Azure Active Directory

  4. Once in Azure Active Directory, look for the Settings in the left hand pane.

  5. In Properties, at the bottom you’ll see the Manage Security defaults button.

  6. It would be turned on by default (Yes) which you’ll need to switch to No.

  7. Once you switch to No, you’ll need to select either of the below reasons as to why you are switching it off. I just entered N/A in the Others reason, your reason could be different.

  8. Once you Save it, that’s all. Now you can just close the Window and try to Login again.

Logging in without Security Defaults

When the Security Defaults is turned off, you can see that the login screen will no longer ask you to enter an authentication method –

  1. When you enter password.

  2. And when you sign in, you’re no longer asked to enter a method for authentication and you’re already logged in past that step.

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  2. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  3. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  4. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  5. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  6. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  7. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!

Create Application Users for Dynamics 365 environment | Power Platform Admin Center

Here’s how you now set up Application Users in Dynamics 365 CRM from the Power Platform Admin Center instead from the Classic UI and let’s see how the process is eased.

Classic UI

Previously, you used to see Application Users view in the Dynamics 365 CRM under Settings > Security > Users.



But it’s not longer available. Instead, you now go to the Power Platform Admin Center.

Register App in Power Platform Admin Center [PPAC]

Now, once you are in the Power Platform Admin Center, you can go to the Environment section –

  1. First, let’s say this is your App in your Azure’s Active Directory in the App Registrations. And now you want to create an Application User in Dynamics CRM for this App.

  2. Now, you can go to the PPAC and in Environments, look for your D365 CRM/Dataverse environment.

  3. In Settings, you’ll see Users, expand the same and you’ll see Application Users which is now it’s own separate option.

  4. Now, you’ll see the Registered Apps I have already and you can add from the “+ New App User” button above.

  5. Now, select the + Add an app button

  6. And you’ll see the complete list of all the Apps that are in your Azure’s Active Directory. Select the one your just created and click Add.

  7. And then finally click Create once you Add the App you want to create Application User for.

  8. And now, you’ll see the App added as an Application User for your environment.

  9. Now, you also need to provide Security Roles based on the requirement. Select the App User, and click on Edit security roles once available.

  10. In my case, I’m giving 3 Roles which I need to give and click Save.

  11. Now, I’ll also see how many Roles have been given to the App User.

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Setup Postman to connect to Dynamics 365 CRM using OAuth 2.0 | Azure App Registration
  2. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  3. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  4. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  5. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  6. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  7. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  8. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  9. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  10. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  11. Call Azure Function from Dynamics 365 CRM using Webhooks
  12. Show Ribbon button only on record selection in Dynamics CRM
  13. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!

Setup Postman to connect to Dynamics 365 CRM using OAuth 2.0 | Azure App Registration

If you want to test the WEB API in Dynamics 365 CRM using Postman, here’s what you need to do to setup Postman to connect to Dynamics 365’s Web API

There are 2 parts to this setup –

  1. Registering an App in Active Directory.
  2. Configuring Postman to utilize the App to connect to Dynamics 365.

So, let’s look at how we do this!

Register an App in Azure

The first step is to register an App in your Azure’s Active Directory so that you can use it to test using your Postman on your machine –

  1. Go to the Azure Portal (https://portal.azure.com/) and the look for or search for Azure Active Directory

  2. In AAD, look for App Registrations.

  3. Now, register a new App in the App Registration

  4. Enter the details of the App Registration so you can identify what the App is for. Since I’m using this for Postman testing, I’ll enter something like – “Postman WEB API
    Also, since in most cases your Azure environment could be different, it’s recommended to select Accounts in any organizational directory (Multitenant), but it’s up to you based on how you can to secure this!
    Since, I’m testing on my local machine using Postman, I’ll enter http://localhost

    And finally click on Register.

  5. Once this is registered, you’ll see the details like any other Azure resource and look for Client ID and copy the same and save it somewhere temporarily.

  6. Next is updating the Manifest to support this setup.
    Set the “allowPublicClient” flag to true and “oauth2AllowImplicitFlow” to true as well.

  7. Once the Manifest is updated, it should look like this –

  8. Final step is to give permissions for Dynamics 365 to this App we just created. Go to API Permissions tab from the left-hand menu and click on + Add a permission button.

  9. Look for the Dynamics CRM option and select it.

  10. Select it and then click on Add permissions.

  11. Once added, you’ll need to Grant Permissions. At this moment when it’s not granted, the Status can be seen as blank.

  12. Select Yes to Grant Permissions.

  13. Once granted, the Status will be updated as follows – the status of Granted for [OrgName] will appear

  14. And we are done setting up the App in Azure Portal to be utilized by Postman to test Dynamics 365 Web API locally.

Setting up Postman

Now that we have the App setup, open Postman and we’ll utilize the above created App to establish a connection with Dynamics 365 CRM using OAuth2.0 –

  1. In your Dynamics 365 CRM environment, capture the OAuth URL in your Customization > Developer Resources section

  2. Enter this in a new Tab in your Postman and if you directly try to test this, you’ll get 401 Unauthorized.

  3. Now, we’ll have to configure the Authorization tab to be able to authenticate into Dynamics 365 CRM using the App registration we created in Azure in steps above.

  4. Now, enter the details we have captured so far –
    Token Name – Enter a suitable Token name
    Grant Type – Select Implicit if not already set.
    Callback URL – The callback URI should be http://localhost based on what we set in Azure in above steps.
    Auth URL – Here’s how you can get the Auth URL for your Dynamics 365 environment -> OAuth 2.0 URL for Dynamics 365
    Client ID – This should be what you saved above from the Azure App Service. Refer to step #5 in the Setting up App in Azure section above in this post. This should be the Application ID.

    Once all this is entered, click on Get New Access Token

  5. Once you click on Get New Access Token, you’ll need to authenticate into the environment as you usually get while connecting from Browser.
    Enter credentials and authenticate.

  6. Once this connection and the permissions are correctly validated, you’ll get a message like this –

  7. And it’ll show you this dialog box where you need to simply click on the Use Token button.

  8. You’ll then see the token as below –

  9. And you’re set!! Now, you can simply test using Postman.

Testing using Postman

Now that you are authenticated, you can click on Send and see that you are now able to retrieve the Web API

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  2. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  3. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  4. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  5. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  6. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  7. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!

OAuth 2.0 URL for Dynamics 365

If you are new to using connecting to Dynamics 365 using OAuth 2.0, here’s an Auth URL you’ll need for your external applications / Postman testing of Web APIs in Dynamics 365 CRM.

URL for OAuth2.0 for Dynamics 365 CRM

The URL is: https://login.microsoftonline.com/common/oauth2/authorize?resource=[URL of the D365 Environment]

In the square brackets, you can put the URL of your Dynamics 365 CRM environment itself like shown below –

And then the URL should be: https://login.microsoftonline.com/common/oauth2/authorize?resource=https://cft158.crm.dynamics.com/

Hope this was helpful! Here are some more Dynamics 365 posts which you might be interested in –

  1. Dynamics 365 Storage Utilization | Dataverse Storage | Power Platform Admin Center
  2. Use Hierarchy in Roll Up Fields in Dynamics 365 CRM
  3. Filter records in a View owned by a Team you are a member of | Dynamics 365 CRM
  4. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  5. Dynamics 365 App For Outlook missing on SiteMap in CRM? Use shortcut link [Quick Tip]
  6. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  7. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  8. Excel Importing Notes (Annotation) entity in Dynamics 365 CRM
  9. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  10. Call Azure Function from Dynamics 365 CRM using Webhooks
  11. Show Ribbon button only on record selection in Dynamics CRM
  12. Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

Thank you!!

Delete App Passwords created by other users in Office 365 | Multi-factor authentication

Now, let’s say you have enabled your users to create their own App Passwords to use in non-browser applications. But, you want to clear the same for a particular user citing there are some security concerns and they needs to be cleared before you start fresh for that user.

Here’s how you can delete App Passwords created for a selected User. Example: Priyesh is a user who has created an App Password since MFA is enforced.

Office 365 Admin Center

In Office 365 Admin Center, go to Users

  1. Once you see all the Active Users, you can simply click on Multi-factor Authentication


  2. Now, you’ll be able to see all the users who use MFA and if they have been enforced and hence, must’ve created their App Passwords. (Only Enforced Users can create app passwords – Allow users to create App Passwords in Office 365 | Multi-factor Authentication)
    Now, let’s select Priyesh’s user settings by selecting the user and then going to Manage User Settings.


  3. In manage Settings for this user, you’ll see the option ‘Delete all existing app passwords generated by the selected user


    Select the same and then Save.

  4. Now, if Priyesh checked the App Passwords / Sign-In (https://mysignins.microsoft.com/security-info), the App Password would be gone!

Hope this was useful! Here are some more Azure / O365 posts you might want to check –

  1. Allow users to create App Passwords in Office 365 | Multi-factor Authentication
  2. Office 365 Outlook connector in Cloud Flows showing Invalid Connection error | Power Automate
  3. Import multiple Users in Office 365
  4. Office 365 Admin: Quickly Enable Multi-factor authentication for users
  5. Connecting XrmToolBox to an MFA enabled Dynamics 365 environment | Azure AD
  6. Log Canvas Power App telemetry data in Azure Application Insights | Power Apps
  7. Retrieve Metadata of Global OptionSets from Dynamics 365 in Power Automate | HTTP with Azure AD action
  8. Office 365 Admin: Quickly Enable Multi-factor authentication for users

Thank you!

Connecting XrmToolBox to an MFA enabled Dynamics 365 environment | Azure AD

It has always been recommended to enable MFA on environments we work on. For developers, it is especially critical that MFA is enabled that developers are also someone who need to connect the https://www.xrmtoolbox.com/ more than ever!

Here’s one of the common challenges in being able to connect to an MFA enabled Dynamics 365 instance using XrmToolBox.

Register the Dynamics 365 environment as an App in Azure

Microsoft has provided a recommended way to register an App with Azure Active Directory and also the same has been mentioned in the XrmToolBox Connection utility. Below is a summary from the original Microsoft Documentation on the same – https://docs.microsoft.com/en-US/powerapps/developer/data-platform/walkthrough-register-app-azure-active-directory?WT.mc_id=DX-MVP-5003911

  1. Go to https://portal.azure.com/ and look for Azure Active Directory.


  2. Once you save it, you’ll get the Application (client) ID which which will be needed by the XrmToolBox while connecting.

  3. Go to the Manifest file and make “allowPublicClient” to true and Save it.

  4. Now, navigate to API Permissions from the left side menu.

  5. Now, search for the permission “Common Data Service” under the tab APIs for my organization uses.

  6. Make sure Delegated Permissions are selected and tick mark user_impersonation and click on Add permissions.


  7. Select the same and your permissions should look like below. Once this is the state, you are done on Azure side.


    Now, let’s connect XrmToolBox to the Dynamics 365 environment.

Connecting to Dynamics 365 using the XrmToolBox

Let’s see what steps you need to follow in order to connect to the Dynamics 365 instance

  1. Open XrmToolBox and create a New Connection.

  2. Now, since you are aware that the environment is MFA enabled, select MFA/OAuth method.


  3. Enter the URL of the Organization and click Next as shown below.


  4. Now, enter the Application ID which you can copy from the registered App in Azure.

  5. If you click on the “Use development Azure AD App”, the Reply Url will be populated automatically. Before that, you’ll see the message notifying which scenarios this is suitable.

  6. Read below. At this point, I haven’t tried the other method and stuck to the below since I connect XrmToolBox to the Dynamics 365 environment for development purpose.


  7. Once you click OK on the above, the Reply Url will be auto-populated and you can proceed further.

  8. Now, enter the username which you want to connect with. Supposedly, this is the one on which MFA is enabled.

  9. Upon clicking Next, you will be asked the Password of the credentials you are using.

  10. Once you’ve entered the same, it will send a request to your Authenticator on the registered device.


  11. One the device, assuming you have the Authenticator App installed already, you can Approve the same to let the Authentication go through.

  12. Upon Approval, the XrmToolBox will be authenticated and it will be connected to the Dynamics 365 environment. As usual, you can then give it a name and click Finish to save it on your XrmToolBox.





Hope this was helpful!!

Here are some more Azure / Dynamics 365 / XrmToolBox related posts you might want to check out –

  1. Find deprecated JS code used in your Dynamics 365 environment | Dynamics 365 v9 JS Validator tool | XrmToolBox
  2. Set Lookups in Xrm.WebApi D365 v9 correctly. Solving ‘Undeclared Property’ error
  3. Understanding Xrm.Page Object ModelForm Access Checker in new Power Apps Form Designer | Model-Driven Apps in Dynamics 365
  4. Use Rich-Text Control for Multiple Lines of Text in Dynamics 365 CE | Quick Tip
  5. Ribbon button visibility based on a field value in Dynamics 365 | Ribbon Workbench
  6. Pass Execution Context to JS Script function as a parameter from a Ribbon button in Dynamics 365 | Ribbon Workbench
  7. Log Canvas Power App telemetry data in Azure Application Insights | Power Apps
  8. Call Azure Function from Dynamics 365 CRM using Webhooks
  9. Use Azure App Passwords for MFA enabled D365 authentication from Console App
  10. Find Created On date of solution components in Solution Layers | Dynamics 365 [Quick Tip]

Thank you!!

Log Canvas Power App telemetry data in Azure Application Insights | Power Apps

Here’s how you can register your Canvas Power App in your Azure’s Application Insights and log telemetry data into Azure.

Some basic info about what all you can see in Application Insights is –

  1. Count of Users who used the app
  2. Events logged, Sessions logged
  3. Device info
  4. Region info

It’s quite simple to set it up! Let’s take a look –

Registering in Application Insights in Azure

First, make sure you do have an Azure Subscription. Let’s look at how you can register an Application Insight record.

  1. Look for Application Insights in Azure in the search bar

  2. Then, among other records, you can register a new one which will identify with your Canvas Power App

  3. Review all that you entered and move ahead

  4. It’ll be deployed pretty quickly within a few minutes unlike some heavy Azure resources

  5. Upon completion, you can navigate to the resource and see the details

    Zoomed In


Add Instrumentation Key to Canvas Power App

Next step is to add the Instrumentation Key to the Canvas Power App

  1. Look for the App itself in the Navigation tree

  2. Once you select that, you can then look at it’s Properties on the right hand side. In Instrumentation Key, paste the Instrumentation Key you copied when you created the App in the Azure.

  3. And to go with that, let’s say my Canvas Power App has some basic structure like below

Using Application Insights

As the users use the Canvas App, the following information is logged –

  1. Navigate to the Usage section in the Application Insights you registered and if you scroll down on the main pane, you can see w

  2. And then scroll down to reveal more Insight data


  3. Or, if you see Events, you can see info like this –

    I’m not completely sure why my users showed high when I tried with only 2 users. But perhaps, once I dive more deeper into using Application Insights and how each of the metrics are read, I’ll come back to update this post. 😊

And likewise, if you know how to read the Application Insights, you can customize this to give you what you need to see.

Here is some Microsoft Documentation on Application Insights to help you out –

  1. https://docs.microsoft.com/en-us/azure/azure-monitor/app/usage-segmentation

Hope this was useful. Here are more Azure/Canvas Power App related posts you might want to check –

  1. Call Azure Function from Dynamics 365 CRM using Webhooks
  2. Use Azure App Passwords for MFA enabled D365 authentication from Console App
  3. Call HTTP Request from a Canvas Power App using Flow and get back Response | Power Automate
  4. Launch URL on a Data Table Text column selection in a Canvas PowerApp | SharePoint Lists
  5. Call HTTP Request from a Canvas Power App using Flow and get back Response | Power Automate
  6. Send a Power App Push Notification using Flow to open a record in Canvas App | Power Automate
  7. Aggregate functions in a Canvas Power App | Using on SharePoint Lists
  8. Count of total CDS records returned in a Canvas Power App connection [Quick Tip]
  9. Dependent OptionSets in a Canvas Power App for 1:N related CDS entities | Power Platform
  10. Implement character length validation in a Canvas Power App | Power Platform

Thank you!

Call Azure Function from Dynamics 365 CRM using Webhooks

This is a vast topic to cover in a blog. But I wanted to write from a bird-eye’s view of how this will pan out in an implementation where you perform a certain operation in Dynamics 365 CRM and an Azure Function is called to perform further operations.

This post is written keeping in mind fair knowledge of Azure Functions, Storage accounts and subscriptions in mind.

I’ll try to keep the article short, so stay with me! 🙂

Create a Function App in Azure

  1. Let’s say you have created a Function App in Azure already and want to connect to Dynamics 365 CRM. Click on the big + New Function button in the screenshot below
    resourceOverview_LI
  2. Now, since I want to keep Visual Studio as my driver for coding and deployment, I’ll create a new Project in Visual Studio of type Azure Functions and click Next
    newProj
  3. On the next page, I’ll give a relevant name and hit Create.
    createProjectButton
  4. Since we will be using Webhooks to connect to the Azure Function, the trigger chosen here is Http Trigger.Make sure you select Framework because Microsoft.Xrm.Sdk assemblies don’t work on .NET Code, but on .NETFramework only.And then you should take care of what your Storage Account and Authorization should be – Finally click Create once done.
    frameWorkSelected
  5. The Project will open with 1 .cs file, so make sure you name your plugin initially –
    accountPluginGetsInApp
  6. It’ll take a while to create the Project. Once created, go to the Portal on Azure and click on the Get Publish Profile
    getPublishProf_LI
    It will be downloaded on the computer. Keep it so that you can import it on the Project in Visual Studio to use for Direct Publish.
    downloadedProfile
  7. Now, right click and chose Publish to make your first push as is so that the Account Function gets pushed to Azure App.
    firstPublish
  8. Then, click on Import and import the Publish Profile settings downloaded in step #5 above –
    selectImport
  9. Once imported, you’ll be taken here – simply Publish once.
    quickPublish
  10. Once Publish is successful, check in the Azure App in Portal, the Function should appear.
    accountPluginGetsInApp

 

Modifying code to read Webhook Call from Dynamics 365

  1. To keep it simple, I’m simply reading the context and then, you can flourish your App further to make it work as required.
    captureContextSo, I’m only reading the request into a String and logging it so that we can see it in the logs in the Azure Function app.
  2. You can use RemoteExecutionContext class to actually get all the contextual information into the Function app and then use it further. See below –
    remotecontext
  3. Once ready with your code, Publish it.

Now, let’s Register the Webhook and call the app.

If you’re also looking for remote debugging, this is a great article-Remote Debugging Azure Functions V2 “The breakpoint will not currently be hit. No symbols have been loaded for this document”

Register a Webhook in Plugin Registration Tool

Coming to Dynamics 365 CRM side of things, you can register a Webhook that will trigger on Account Name update to fire off the AccountPlugin Function App created above –

  1. In Plugin Registration Tool, register a new Webhook
    registerWebHook
  2. Enter Webhook Details. Select Authentication type as WebhookKey
    enterWebhookDetails
  3. Now, to get the key, go to the Function App in portal, and look </> Get function URL link.
    getKeyandURL
  4. Copy the same and paste in Notepad, separate the code part from the main URL
    selectCopy
    separateCodePart
  5. Paste the URL part in Endpoint URL and key in the Value field. Click Save.
    registerWebHookWIthDetails
  6. Now, add a Step to the Webhook. For this example, I’ve chosen update of Account‘s Account Name field
    addStepregisterStepInWebhook
    And Register it.

Execution

  1. The purpose was to simply ready Dynamics 365 Account record upon modification of the Account Name
    recordChange
    And save the record.
  2. In a minute or so, the Log will be generated (only the logs take a little longer to generate)
    triggered
    And thus, we are able to send data / or rather, call Azure Function and process Dynamics 365 CRM data using Webhooks.

Some other Azure related post you might like to look at – Use Azure App Passwords for MFA enabled D365 authentication from Console App

Hope this was helpful! Tried my best to keep it basic and short as possible. I’m sure you all will explore way beyond and develop awesome implementations!