Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

Microsoft Dynamics 365 for Operations Connector

The Microsoft Dynamics 365 for Operations Connector for Anypoint platform enables integration with Microsoft Dynamics 365 for Operations Web API.

This connector lets you perform these operations:

  • Authorize or unauthorize access to a Microsoft Dynamics 365 for Operations server.

  • Create a recurring job on Microsoft Dynamics 365 for Operations server.

  • Retrieve multiple entities.

  • Retrieve multiple entities using the DataSense Query Language.

  • Execute operations.

Prerequisites

This document assumes that you are familiar with Microsoft Dynamics 365 for Operations, Mule, Anypoint Connectors, Anypoint Studio, Mule concepts, elements in a Mule flow, and Global Elements.

You need login credentials to test your connection to your target resource.

For hardware and software requirements and compatibility information, see the Connector Release Notes.

To use this connector with Maven, view the pom.xml dependency information in the Dependency Snippets in Anypoint Exchange.

Before starting, you need access to a Microsoft Dynamics 365 instance (online or on-premise) managed by Azure Active Directory.

What’s New in this Connector

This connector is the first release for Mule 4.

Connect in Design Center

  1. Click a trigger. You can create a global element by selecting this connector as they trigger. If a global element is not needed, you can use an HTTP Listener or Scheduler trigger.

  2. To create an optional global element for the connector, you can choose from the following options:

    Design Center config name and connection type

  3. Select the plus sign to add a component.

  4. Select the connector as a component.

  5. Click Set Up > Upload, browse for and select the driver for this connector on your file system, and upload it. Alternatively, search for and select a driver that is already uploaded.

  6. Configure the Data Query URL field for the Retrieve Multiple operation. This is used by a query to retrieve data.

    Retrieve Multiple Data Query URL field

Required Parameters for the OAuth 2.0 Configuration

For information regarding required configurations, view the See Also section of this document for the Authorize access to web applications using OAuth 2.0 and Azure Active Directory link. To find the authorization URL and the access token URL you can go to the Azure portal, App registrations section and select the Endpoints menu.

  • Consumer Key - The application ID assigned to your app when you registered it with Azure Active Directory. You can find this in the Azure Portal (portal.azure.com). Click Active Directory, click the directory, choose the application, and click Configure.

  • Consumer Secret - The application secret that you created in the app registration portal for your app. This should not be used in a native app, because client secrets cannot be reliably stored on devices. This is required for web apps and web APIs, which have the ability to store the client secret securely on the server side. You can find this in the Azure Portal (portal.azure.com).

  • Authorization URL - Tenant specific OAuth2.0 endpoint; format: https://login.microsoftonline.com/{tenant}/oauth2/authorize (follow instructions presented in the above link for specific information on how to obtain the endpoint)

  • Access token URL - Tenant specific endpoint for requesting the access token; format: https://login.microsoftonline.com/{tenant}/oauth2/token (follow instructions presented in the above link for specific information on how to obtain the endpoint).

  • Listener config - Name of the HTTP listener instance created in studio flow

  • Callback path - The URL of your app, where authentication responses can be sent and received by your app (follow instructions presented in the above link for specific information on how to obtain the endpoint).

  • Authorize path - The URL which triggers the OAuth mechanism.

  • External callback URL - Optional: Configure if the callback URL is not accessible directly (example: when using proxies) example format: http://localhost:8081/callback

    Design Center OAuth configuration

Required Parameters for the OAuth 2.0 Username-Password

For information regarding required configuration, see Authorize access to web applications using OAuth 2.0 and Azure Active Directory in the See Also section of this document.

  • Username - Username used to initialize the session.

  • Password - Password used to authenticate the user.

  • Resource - The application ID URI of the web API (secured resource). This must be the root URI, without specifying the version. Example: https://YOUR_ORG.operations.dynamics.com/

  • Client ID - The application ID assigned to your app when you registered it with Azure Active Directory. You can find this in the Azure Portal (portal.azure.com). Click Active Directory, click the directory, choose the application, and click Configure.

  • Client Secret - The application secret that you created in the app registration portal for your app. This should not be used in a native app, because client secrets cannot be reliably stored on devices. This is required for web apps and web APIs, which have the ability to store the client secret securely on the server side. You can find this in the Azure Portal (portal.azure.com).

  • Token Request Endpoint - The token endpoint that is called to get the access token. Example: https://login.windows.net/TENANT_ID/oauth2/token where TENANT_ID is the Azure Active Directory ID.

Design Center OAuth username and password config

Connect in Anypoint Studio 7

You can use this connector in Anypoint Studio by first downloading it from Exchange and configuring it as needed.

Install Connector in Studio

  1. In Anypoint Studio, click the Exchange icon in the Studio taskbar.

  2. Click Login in Anypoint Exchange.

  3. Search for this connector and click Install.

  4. Follow the prompts to install this connector.

When Studio has an update, a message displays in the lower right corner, which you can click to install the update.

Configure in Studio

  1. Drag and drop the connector to the Studio Canvas.

  2. To create a global element for the connector, set these fields:

    1. OAuth 2.0

      • Consumer Key - The application ID assigned to your app when you registered it with Azure Active Directory. You can find this in the Azure Portal (portal.azure.com). Click Active Directory, click the directory, choose the application, and click Configure.

      • Consumer Secret - The application secret that you created in the app registration portal for your app. This should not be used in a native app, because client secrets cannot be reliably stored on devices. This is required for web apps and web APIs, which have the ability to store the client secret securely on the server side. You can find this in the Azure Portal (portal.azure.com).

      • Authorization URL - Tenant specific OAuth2.0 endpoint. Format: https://login.microsoftonline.com/{tenant}/oauth2/authorize (follow instructions presented in the above link for specific information on how to obtain the endpoint)

      • Access token URL - Tenant specific endpoint for requesting the access token; format: https://login.microsoftonline.com/{tenant}/oauth2/token (follow instructions presented in the above link for specific information on how to obtain the endpoint).

      • Listener config - Name of the HTTP listener instance created in studio flow

      • Callback path - The URL of your app, where authentication responses can be sent and received by your app (follow instructions presented in the above link for specific information on how to obtain the endpoint).

      • Authorize path - The URL which triggers the OAuth mechanism

      • External callback URL - Optional: configure this if the callback URL is not accessible directly (example: when using proxies) example format: http://localhost:8081/callback.

        Studio OAuth configuration

    2. OAuth 2.0 Username-Password

      • Username - Username used to initialize the session.

      • Password - Password used to authenticate the user.

      • Resource - The application ID URI of the web API (secured resource). This must be the root URI, without specifying the version. Example: https://YOUR_ORG.operations.dynamics.com/

      • Client ID - The application ID assigned to your app when you registered it with Azure Active Directory. You can find this in the Azure Portal (portal.azure.com). Click Active Directory, click the directory, choose the application, and click Configure.

      • Client Secret - The application secret that you created in the app registration portal for your app. This should not be used in a native app, because client secrets cannot be reliably stored on devices. This is required for web apps and web APIs, which have the ability to store the client secret securely on the server side. You can find this in the Azure Portal (portal.azure.com).

      • Token Request Endpoint - The token endpoint that is called to get the access token. Example: https://login.windows.net/TENANT_ID/oauth2/token where TENANT_ID is the Azure Active Directory ID.

        Studio OAuth Username Password configuration

Use Case: Studio

  1. Listener(HTTP) - accepts data from HTTP requests.

  2. Dynamics AX for Operations - Connects with Dynamics for Operations and executes a query to retrieve all the Customer entities.

  3. Transform message - outputs the results of the Retrieve multiple operation in JSON format.

    Studio 7 dynamics-op-testFlow icons

USE Case: XML

Paste this XML code into Anypoint Studio to experiment with the flow described in the previous section.


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:dynamics365ForOperations="http://www.mulesoft.org/schema/mule/dynamics365ForOperations"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/dynamics365ForOperations
http://www.mulesoft.org/schema/mule/dynamics365ForOperations/current/mule-dynamics365ForOperations.xsd">
        <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config">
                <http:listener-connection host="localhost" port="8081" />
        </http:listener-config>
        <dynamics365ForOperations:dynamics-365-for-operations-config name="Dynamics_365_For_Operations_Dynamics_365_for_operations" doc:name="Dynamics 365 For Operations Dynamics 365 for operations">
                <dynamics365ForOperations:oauth2-user-password-connection
                username="USERNAME"
                password="PASSWORD"
                resource="https://muledev.sandbox.operations.dynamics.com"
                clientId="CLIENT_ID"
                clientSecret="CLIENT_SECRET"
                tokenRequestEndpoint="https://login.windows.net/TOKEN/oauth2/token" />
        </dynamics365ForOperations:dynamics-365-for-operations-config>
        <dynamics365ForOperations:dynamics-365-for-operations-config
        name="Dynamics_365_For_Operations_Dynamics_365_for_operations1"
        doc:name="Dynamics 365 For Operations Dynamics 365 for operations">
                <dynamics365ForOperations:oauth2-user-password-connection username="${operations.username}" password="${operations.password}" resource="${operations.resource}" clientId="${operations.client_id}" clientSecret="${operations.client_secret}" tokenRequestEndpoint="${operations.request_endpoint}" />
        </dynamics365ForOperations:dynamics-365-for-operations-config>
        <flow name="dynamics-op-testFlow">
                <http:listener doc:name="Listener" config-ref="HTTP_Listener_config"
                path="/retrieve"/>
                <dynamics365ForOperations:retrieve-multiple doc:name="Retrieve multiple"
                config-ref="Dynamics_365_For_Operations_Dynamics_365_for_operations1">
                        <dynamics365ForOperations:data-query-url ><![CDATA[https://muledev.sandbox.operations.dynamics.com/data/Customers]]></dynamics365ForOperations:data-query-url>
                </dynamics365ForOperations:retrieve-multiple>
                <ee:transform doc:name="Transform Message">
                        <ee:message >
                                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
                        </ee:message>
                </ee:transform>
        </flow>
</mule>