Skip to content

Setting up the Microsoft Dynamics365 Environment with Azure

The Microsoft Dynamics 365 (Microsoft Dynamics CRM) Connector allows you to access the Microsoft Dynamics 365 Web API through WSO2 Enterprise Integrator. The Microsoft Dynamics CRM system (now known as Microsoft Dynamics 365) is a standalone CRM product from Microsoft that provides sales, marketing, and service management capabilities only via individual modules.

To use the Microsoft Dynamics 365, you must have folowing accounts.

  • A Microsoft Dynamics 365 (online) system user account with administrator role for the Microsoft Office 365 subscription
  • A Microsoft Azure subscription for application registration

Authentication to Dynamics 365 using Azure Apps

Dynamics 365 authentication is recommended only through Azure AD (for online instances). To achieve this,

  1. Create and configure the app in Azure Active Directory.
  2. Create a user in Azure AD and configure it as an application user in Dynamics 365
  3. Generate the Access Token and make requests to Dynamics 365 with the above-generated Access Token.

  4. Setting Up an App in Azure

    1. Navigate to the Azure portal and select Create an Azure Account.

      Note: If you creating a Azure account you should get a Microsoft Azure subscription for application registration. Purchase Azure services directly from Microsoft with pay-as-you-go-pricing. This offer is billed at the standard Pay-As-You-Go rates.

    2. Log in to the created Azure account.

    Azure Management Console

    1. Navigate to Azure Active Directory –> App Registration –> New Application registration.

    Azure new application registration console

    1. Now fill in the required fields as shown below and hit Register.

    Register an application

    Note:Note that the sign-on URL only matters for something like a single page application – otherwise just putting a localhost URL is just fine.

    1. Select created Application.

    Created TestWebAPI application

    1. Now you have successfully created an Azure app. Double click the app and you will see its details as shown below. Copy the value of the Application (client) ID and Directory (tenant) ID.

    Application ID

    1. You need to give permission to the app to access Dynamics 365. Navigate to View API permissions.

    View API permissions

    1. Click Add a permission.

    Add a permission

    1. Then select Dynamics CRM.

    Select an API

    1. Make sure to check the Delegated Permissions checkboxes as shown below. Select permissions and click Add permission.

      Select CRM permission

    2. Click on Grant Permissions and click Yes.

      Grant permission

    3. After setting up CRM permissions you will see following console.

      After setup CRM permissions

    4. Now you need to create secret keys. Navigate to Certificates & secrets.

      Create certificate and secrets

    5. Click New client secrets.

      New client secret

    6. Add Description and Expires values. Click Add and copy the value.

      Add client secret

    7. Search Users inside the Azure Active Directory and Create New user (this user would be linked to the Application User, which is created in the Dynamics 365 CRM).

      Create new user

    8. Fill all mandatory fields and click Create.

      Fill new user details

  5. Setting Up the Application user in Microsoft Dynamics 365 CRM

    1. Navigate to Microsoft Dynamics 365 account and select Create a Dynamics 365 Account.

    2. Log in to the created Dynamics 365 account. Click the Admin icon.

    Dynamics365 admin center

    1. Click Show all from the dropdown in the left corner scroll bar.

    Dynamics365 show all

    1. Click All admin centers and click Dynamics 365 icon. It will navigate to the Power Platform admin center.

    Dynamics365 all admin center

    1. Select the created environment and click Open environment.

    Dynamics365 select environment

    1. Navigate to Settings.

    Dynamics365 settings

    1. Click Security -> Users.

    Dynamics365 users

    1. Choose Application Users in the view filter.Select -> New.

    Filter application users

    1. In the Application User form, enter the required information.

    Dynamics365 new application user

    The user name information must not match a user that exists in the Azure Active Directory. In the Application ID field, enter the application ID of the app you registered earlier in the Azure AD.

    1. If all goes well, after selecting SAVE, the Application ID URI and Azure AD Object Id fields will auto-populate with correct values.

      Dynamics365 created application user

    2. Before exiting the user form, choose MANAGE ROLES and assign a security role to this application user so that the application user can access the desired organization data.

Generate Access Token

After setting up Azure and Microsoft Dynamics 365 CRM, you can get the access token by invoking the following HTTP request.


Header: Content-Type: application/json

Body: x-www-form-urlencoded

Key Value
client_id Application ID of the registered app in Azure.
resource (Dynamics 365 Online Insance URL
Client_secret Key value from the registered app in Azure
Grant_type client_credentials

Please note you need to replace the with an actual value from your registered app.

Make a request using Postman as below.

Obtaining access token

You need to copy and save the following parameter values to proceed with configuring the WSO2 Microsoft Dynamics 365 Connector.

Key Value
apiUrl The instance URL for your organization.
accessToken Value of the Access Token to access the Microsoft Dynamic CRM Web API via request.
clientSecret The secret key of the application that is registered in the Azure AD.
resource The App ID URI of the web API (E.g "