Microsoft Dynamics 365 as Data Source

Setup AzureAD

Bildschirmfoto 2022-10-26 um 09.15.46.png


Add New App Registration

Add a new registration under App registrations > New registration.

Screenshot 2022-03-15 at 15.36.16.png

Tipp: When naming the new app, choosing a recognisable name like External Data for Confluence can help you to properly identify the application later.

Bildschirmfoto 2022-10-26 um 09.39.42.png

Certificates & Secret

Go to Certificates & secrets > Client secrets > New client secret

Add a meaningful description and set an expiration date. Keep in mind that you’ll have to update the data source once the secret expires.

Important: Please make sure to note down the secret value, which is only visible immediately after creation. You will need this value later when setting up the data source

Screenshot 2022-03-15 at 15.52.46.png

API Permissions

Go to API permissions > Add a permission

Select Dynamics CRM > Application permissions

Now select the API / Permission user_impersonation.

Bildschirmfoto 2022-10-26 um 09.44.32.png

Collect Endpoint & ClientID

Go to Overview > Endpoints and copy the following endpoint:

OAuth 2.0 token endpoint (v2)

Go to Overview > Application (client) ID and note the value.


Associate App User / Set Roles in CRM 365 / Dataverse Environment

Sign in to the Power Platform admin center as a System Administrator.

Select your environment, in our sample “w04ss”

Bildschirmfoto 2022-10-26 um 10.03.36.png

Got to Settings -> User + permissions -> Application users and create a new app user.

Bildschirmfoto 2022-10-26 um 10.04.52.png

Choose the app we created earlier in Azure AD, your business unit and the right role for this user.
For demo purpose we select Systemadministrator and should not be used in production!

Bildschirmfoto 2022-10-26 um 10.07.48.png

Setup External Data

Create New Data Source

Create a new data source under External Data for Confluence > Data Sources > Add Data Source.

Authentication:

Select Authentication OAuth2 > Grant Type > Client Credentials

Client ID & Client Secret

Enter the Client ID, which you can find at Overview > Application (client) ID

The Client Secret is the secret value created in the Certificates & secrets section. Please insert the noted value here.

Endpoints

Endpoints are service specific URLs for receiving an access token. Since we are using the client credentials flow, we only need the token endpoint.

Token Endpoints:

Token Url: https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token

Scopes

Scopes define the permission to specific parts of the data. Since we are using the Client Credentials Flow, we simply set the scope to:

https://{businessunit}.crm4.dynamics.com/.default

Make sure that an administrator grants you the required permissions that you need for setting up the Azure backend configuration.

Authenticate

Click Authenticate to retrieve your access token.

Bildschirmfoto 2022-10-26 um 11.14.04.png


URL

To find the Web API URL for your environment:

  1. Sign into Power Apps, and select your environment from the top-right corner.

  2. Select the Settings button in the top-right corner, and select Developer resources.

Bildschirmfoto 2022-10-26 um 11.25.09.png

Example query: (Microsoft Documentation)

https://{Your Web API endpoint}/accounts?$select=name

In our example:

https://orgfc1f9584.api.crm4.dynamics.com/api/data/v9.2/accounts?$select=name

Result:

Bildschirmfoto 2022-10-26 um 11.17.46.png


Save and test the data source to ensure that everything works as intended.