You can load data from Cognite Data Fusion (CDF) into Microsoft Power Apps, where you can build custom apps for your business needs.
This article explains how to create and connect a custom Power Apps connector with the Cognite API and build a canvas app.
Before you start
To perform the steps below, you need to be an administrator of Azure AD. Make sure you have registered the Cognite API and the CDF portal application in Azure AD and set up Azure AD and CDF groups to control access to CDF data.
You'll also need to register a custom web app in Azure AD to give Power Apps access to the CDF data. Make sure to register the redirect URI, https://global.consent.azure-apim.net/redirect
under Authentication > Add a platform > Web.
Step 1: Create and authenticate a custom connector
-
Sign in to Microsoft Power Apps with your Microsoft account.
-
Start from Dataverse > Custom Connectors.
-
Select New custom connector > Create from blank.
-
On the General information tab:
- Host: Enter
https://<clustername>.cognitedata.com
as host URL. - Optionally, fill in the remaining fields.
- Select Create connector.
- Host: Enter
-
On the Security tab:
- Authentication type: Select OAuth 2.0.
- Identity provider: Select Generic OAuth 2.
- Client id is the ID of the application in Azure AD.Read more.
- Client secret is the client secret of the application in Azure AD.
- Authorization URL:
https://login.microsoftonline.com/<AAD_tenant_id>/oauth2/v2.0/authorize
- Token URL:
https://login.microsoftonline.com/<AAD_tenant_id>/oauth2/v2.0/token
- Refresh URL is identical to the token URL.
- Scope:
<clustername>.cognitedata.com/user_impersonation offline_access
- Redirect URL: Leave this field empty.
-
Select Update connector.
-
On the Definition tab:
- Under Actions, select New action.
- Enter a summary, a verbose description, and an operation ID that identifies the action.
In the Request section:
- Select Import from sample.
- Select the action you want to perform, for instance,
GET
. - Insert the request URL, for instance, https://api.cognitedata.com/api/v1/#operation/getAsset.
- Select Import.
In the Response section:
- Select Add default response.
- Copy the response sample from the Cognite API docs for the action and paste it into the Body field.
- Select Import and make sure the validation succeeds.
- Select Update connector.
-
On the Test tab:
- Select the connection created above and click Test Operation.
Step 2: Build an app using the custom CDF connector
-
Sign in to Microsoft Power Apps with your Microsoft account.
-
Start from Home and select Blank app > Blank canvas app.
-
Click Create, enter an app name, and select a format.
-
Select Data () in the sidebar and find the connector you created above as the data source.
-
Under Insert, select Label, and fetch the properties you want to show in the app by entering a Text function in the formula bar. For instance, the asset name. Read more about formulas.
-
Continue to fetch the properties you want to add to the app, such as data tables, charts, etc.
-
Select Save and Publish and share the app with other users.