Редагувати

Поділитися через


Integrate with Power Platform and Logic Apps using the Azure Digital Twins connector

You can integrate Azure Digital Twins into a Microsoft Power Platform or Azure Logic Apps flow, using the Azure Digital Twins Power Platform connector.

The connector is a wrapper around the Azure Digital Twins data plane APIs for twin, model and query operations, which allows the underlying service to talk to Microsoft Power Automate, Microsoft Power Apps, and Azure Logic Apps. The connector provides a way for users to connect their accounts and leverage a set of prebuilt actions to build their apps and workflows.

For an introduction to the connector, including a quick demo, watch the following IoT show video:

You can also complete a basic walkthrough in the blog post Simplify building automated workflows and apps powered by Azure Digital Twins. For more information about the connector, including a complete list of the connector's actions and their parameters, see the Azure Digital Twins connector reference documentation.

Prerequisites

If you don't have an Azure subscription, create a free account before you begin. Sign in to the Azure portal with your account.

To work with Azure Digital Twins in this article, you'll need an Azure Digital Twins instance and the required permissions for using it. If you already have an Azure Digital Twins instance set up, you can use that instance and skip to the next section. Otherwise, follow the instructions in Set up an instance and authentication. The instructions contain information to help you verify that you've completed each step successfully.

After you set up your instance, make a note of the instance's host name. You can find the host name in the Azure portal.

Lastly, you'll need to set up any Power Platform services where you want to use the connector.

Set up the connector

For Power Automate and Power Apps, set up the connection first before creating a flow. Follow the steps below to add the connection in Power Automate and Power Apps.

  1. Select Connections from the left navigation menu (in Power Automate, it's under the Data heading). On the Connections page, select + New connection.
  2. Search for Azure Digital Twins, and select the Azure Digital Twins (preview) connector.
  3. Where the connector asks for ADT Instance Name, enter the host name of your instance.
  4. Enter your authentication details when requested to finish setting up the connection.
  5. To verify that the connection has been created, look for it on the Connections page. Screenshot of Power Automate, showing the Azure Digital Twins connection on the Connections page.

For Logic Apps, you can use the Azure Digital Twins built-in connection when you create a flow in the next section. For more information on built-in connectors, see Built-in connectors in Azure Logic Apps.

Create a flow

You can incorporate Azure Digital Twins into Power Automate flows, Logic Apps flows, or Power Apps applications. Using the Azure Digital Twins connector and over 700 other Power Platform connectors, you can ingest data from other systems into your twins, or respond to system events.

Follow the steps below to create a sample flow with the connector in Power Automate.

  1. In Power Automate, select My flows from the left navigation menu. Select + New flow and Instant cloud flow.
  2. Enter a Flow name and select Manually trigger a flow from the list of triggers. Create the flow.
  3. Add a step to the flow, and search for Azure Digital Twins to find the connection. Select the Azure Digital Twins connection. Screenshot of Power Automate, showing the Azure Digital Twins connector in a new flow.
  4. You'll see a list of all the actions that are available with the connector. Pick one of them to interact with the Azure Digital Twins APIs. Screenshot of Power Automate, showing all the actions for the Azure Digital Twins connector.
  5. You can continue to edit or add more steps to your workflow, using other connectors to build out your integration scenario. Screenshot of Power Automate, showing a Get twin by ID action from the Azure Digital Twins connector in a flow.

Follow the steps below to create a sample flow with the connector in Power Apps.

  1. In Power Apps, select + Create from the left navigation menu. Select Blank app and follow the prompts to create a new app.
  2. In the app builder, select Data from the left navigation menu. Select Add data and search for Azure Digital Twins to find the data connection. Select the Azure Digital Twins connection. Screenshot of Power Apps, showing the Azure Digital Twins connector as a data source.
  3. Now, the actions from the Azure Digital Twins connector will be available as functions to use in your app. Screenshot of Power Apps, showing the Get twin by ID action being used in a function.
  4. You can continue to build out your application with access to Azure Digital Twins data. For more information about building Power Apps, see Overview of creating apps in Power Apps.

Follow the steps below to create a sample flow with the connector in Logic Apps.

  1. Navigate to your logic app in the Azure portal. Select Workflows from the left navigation menu, and + Add. Follow the prompts to create a new workflow.
  2. Select your new flow and enter into the Designer.
  3. Add a trigger to your app.
  4. Select Choose an operation to add an action from the Azure Digital Twins connector. Search for Azure Digital Twins on the Azure tab to find the data connection. Select the Azure Digital Twins connection. Screenshot of Logic Apps, showing the Azure Digital Twins connector.
  5. You'll see a list of all the actions that are available with the connector. Pick one of them to interact with the Azure Digital Twins APIs.
  6. After selecting an action from the Azure Digital Twins connector, you'll be asked to enter authentication details to create the connection.
  7. You can continue to edit or add more steps to your workflow, using other connectors to build out your integration scenario.

Limitations and suggestions

Here are some limitations of the connector and suggestions for working with them.

  • Some connector actions (such as Add Model) require input in the form of a literal string that starts with @. In these cases, escape the @ character by using @@ instead. This will keep the literal value from being interpreted as a JSON expression.
  • Since Azure Digital Twins deals with dynamic schema responses, you should parse the JSON received from the APIs before consuming it in your application. For example, here's a set of calls that parse the data before extracting the dtId value: Set(jsonVal, AzureDigitalTwins.GetTwinById("your_twin_id").result); Set(parsedResp, ParseJSON(jsonVal)); Set( DtId, Text(parsedResp.'$dtId'));.

Next steps

For more information about Power Platform connectors, including how to use them in workflows across multiple products, see the Power Platform and Azure Logic Apps connectors documentation.