Microsoft Dynamics 365 for Operations Connector 2.0

Microsoft Dynamics 365 for Operations 用 Anypoint Connector を使用すると、Microsoft Dynamics 365 for Operations Web API とのインテグレーションが可能になります。このコネクタは、Anypoint Studio を使用して設定することできます。このコネクタでは、OAuth 2、またはユーザー名とパスワードを使用した OAuth 2 の接続種別が可能です。

このコネクタにより、次の操作を実行できるようになります。

  • Microsoft Dynamics 365 for Operations サーバーへのアクセスの認証または認証の取り消しを行う

  • Microsoft Dynamics 365 for Operations サーバーに定期的なジョブを作成する

  • 複数のエントリを取得する (DataSense クエリ言語を使用した取得を含む)

  • 操作を実行する

始める前に

  • ソフトウェアの要件および互換性に関する情報は、​「Microsoft Dynamics 365 for Operations Connector リリースノート」​を参照してください。

  • Microsoft Dynamics 365 for Operations および Anypoint Platform (Mule Runtime Engine、Anypoint Studio、Mule フローの要素、グローバル要素を含む) に精通していること。

  • 対象リソースへの接続をテストするには、ログイン情報が必要です。

  • Apache Maven でこのコネクタを使用するには、 Anypoint Exchange​ のこのコネクタの ​[Dependency Snippets (連動関係スニペット)]​ で ​pom.xml​ ファイルの連動関係情報を確認してください。

  • Azure Active Directory で管理される Microsoft Dynamics 365 インスタンス (オンラインまたはオンプレミス) へのアクセス権が必要です。

POM ファイル情報

<dependency>
  <groupId>com.mulesoft.connectors</groupId>
  <artifactId>mule-microsoft-dynamics365-for-operations-connector</artifactId>
  <version>x.x.x</version>
  <classifier>mule-plugin</classifier>
</dependency>

x.x.x​ を使用しているコネクタに対応するバージョンに置き換えます。

最新の ​pom.xml​ ファイル情報を取得するには、​ Anypoint Exchange​ でコネクタにアクセスし、​[Dependency Snippets (連動関係スニペット)]​ をクリックします。

Anypoint Studio 7 での接続

Anypoint Studio でコネクタを設定する手順は、次のとおりです。

  1. プロジェクトにコネクタを追加します。

  2. コネクタを設定します。

  3. コネクタの入力元を設定します。

Exchange を使用してコネクタを追加する

  1. Studio で Mule プロジェクトを作成します。

  2. Studio タスクバーの左上にある Exchange ​(X)​ アイコンをクリックします。

  3. Exchange で、​[Login (ログイン)]​ をクリックし、Anypoint Platform のユーザー名とパスワードを指定します。

  4. Exchange で、「Operations」を検索します。

  5. [Microsoft Dynamics 365 for Operations Connector]​ を選択して ​[Add to project (プロジェクトに追加)]​ をクリックします。

  6. 画面の指示に従ってコネクタをインストールします。

Studio でコネクタに追加する

  1. Studio で Mule プロジェクトを作成します。

  2. [Mule Palette (Mule パレット)] で、​[(X) Search in Exchange ((X) Exchange 内を検索)]​ をクリックします。

  3. [Add Modules to Project (モジュールをプロジェクトに追加)]​ で、検索項目に「Operations」と入力します。

  4. [Available modules (使用可能なモジュール)]​ で ​[Microsoft Dynamics 365 for Operations Connector]​ をクリックします。

  5. [Add (追加)]​ をクリックします。

  6. [Finish (完了)]​ をクリックします。

Studio で設定する

コネクタを Studio キャンバスにドラッグします。

次のグローバル要素を作成します。

OAuth 2 の設定

項目 説明

Resource (リソース)

OAuth エンドポイント URL。

Consumer Key (コンシューマーキー)

アプリケーションを Azure Active Directory に登録したときに割り当てられたアプリケーション ID。この ID は Azure Portal (portal.azure.com) で確認できます。​[Active Directory]​ をクリックして、ディレクトリをクリックし、アプリケーションを選択してから ​[Configure (設定)]​ をクリックします。

Consumer Secret (コンシューマーシークレット)

アプリケーション登録ポータルでアプリケーション用に作成したシークレット。クライアントシークレットは信頼のおける方法でデバイスに保存できないため、このシークレットをネイティブアプリケーションで使用しないでください。この情報は Web アプリケーションと Web API で必要です (クライアントシークレットをサーバー側で安全に保存できます)。この ID は Azure Portal (portal.azure.com) で確認できます。クライアントシークレットは、アプリケーションと Azure サーバーのみに公開されている数値であり、これによりアプリケーションにアクセスできます。

Authorization URL (認証 URL)

テナント固有の OAuth2.0 エンドポイント。​https://login.microsoftonline.com/{tenant}/oauth2/authorize​ の形式です (エンドポイントの具体的な情報の取得方法については、以前のリンク先に記載されている手順に従ってください)。

Access token URL (アクセストークン URL)

アクセストークンを要求するためのテナント固有のエンドポイント。​https://login.microsoftonline.com/{tenant}/oauth2/token​ の形式です (エンドポイントの具体的な情報の取得方法については、以前のリンク先に記載されている手順に従ってください)。

Listener config (リスナー設定)

Anypoint Studio のフローで作成された HTTP リスナーインスタンスの名前。

Callback path (コールバックパス)

アプリケーションの URL で、アプリケーションが認証応答の送受信に使用できる (エンドポイントの具体的な取得方法については、上記のリンク先に記載されている手順に従ってください)。

Authorize path (認証パス)

OAuth メカニズムをトリガーする URL。

External callback URL (外部コールバック URL)

コールバック URL に直接アクセスできない場合 (例: プロキシを使用する場合) にのみ必須。​http://localhost:8081/callback​ のような形式です。

microsoft 365 ops as oauth2

OAuth 2 ユーザー名/パスワードの設定

項目 説明

Username (ユーザー名)

セッションの初期化に使用するユーザー名。

Password (パスワード)

ユーザーの認証に使用するパスワード。

リソース

Web API のアプリケーション ID URI (セキュアなリソース)。バージョンを指定しない、ルート URI である必要があります (例: https://YOUR_ORG.operations.dynamics.com/​)。

Client ID (クライアント ID)

アプリケーションを Azure Active Directory に登録したときに割り当てられた ID。この ID は Azure Portal (portal.azure.com) で確認できます。[Active Directory] をクリックして、ディレクトリをクリックし、アプリケーションを選択してから [Configure (設定)] をクリックします。

Client Secret (クライアントシークレット)

アプリケーション登録ポータルでアプリケーション用に作成したシークレット。クライアントシークレットは信頼のおける方法でデバイスに保存できないため、このシークレットをネイティブアプリケーションで使用しないでください。この情報は Web アプリケーションと Web API で必要です (クライアントシークレットをサーバー側で安全に保存できます)。この ID は Azure Portal (portal.azure.com) で確認できます。クライアントシークレットは、アプリケーションと Azure サーバーのみに公開されている数値であり、これによりアプリケーションにアクセスできます。

Token Request Endpoint (トークン要求エンドポイント)

アクセストークンを取得するためにコールされるトークンエンドポイント。例: https://login.windows.net/TENANT_ID/oauth2/token​。この場合の TENANT_ID は Azure Active Directory ID です。

microsoft 365 ops as oauth username pass

ユースケース: データを受け入れて JSON に出力する

このユースケースでは、​Retrieve Multiple​ 操作を使用して Microsoft Dynamics 365 for Operations の機能を操作できます。

  1. Listener (HTTP) (リスナー (HTTP)) - HTTP 要求のデータを受け入れる。

  2. Dynamics AX for Operations - 接続し、顧客のエンティティをすべて取得するクエリを実行する。

  3. Transform message (メッセージの変換) - ​Retrieve Multiple​ 操作の結果を JSON 形式で出力する。

microsoft 365 ops studio use case

プロパティファイルを使用して、フローで使用する次の属性を定義します。

  • username="${operations.username}"

  • password="${operations.password}"

  • resource="${operations.resource}"

  • clientId="${operations.client_id}"

  • clientSecret="${operations.client_secret}"

  • tokenRequestEndpoint="${operations.request_endpoint}"

次の XML コードを Anypoint Studio に貼り付けて、フローを試してください。

<?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>