Breyta

Deila með


Install and configure Connected Field Service for Azure IoT Hub

Follow the steps in this article to set up Connected Field Service for use with Azure IoT Hub.

Important

The device readings chart is no longer available. It relied on Azure Time Series Insights, which was retired on July 7, 2024. Learn more: Migrate from Time Series Insights.

Prerequisites

Tip

Images that include an icon that looks like this: may be expanded to show more detail. Select the image to expand it. To close it, press the Esc key.

Deploy Connected Field Service and Azure resources from an ARM template

Use an Azure Resource Management (Azure Resource Manager) template to deploy Azure IoT Hub and connect it to your Field Service environment.

  1. Select Deploy to Azure on the page https://github.com/microsoft/Dynamics-365-Connected-Field-Service-Deployment.

  2. Select your Azure subscription.

  3. Select a resource group or create one.

  4. Set the region to the same region as your Field Service environment.

    Screenshot of the Azure Resource Manager template to deploy IoT Hub for Connected Field Service.

  5. Enter the unique name of your organization and the organization URL of the Field Service environment.

  6. Select the optional resources you want to deploy.

    • Select Deploy SQL Server for Power BI (optional) and enter the SQL server and credentials to create your own reports in Power BI.
  7. Select Review + create.

Make sure the deployment is complete before you proceed.

Create an IoT provider instance

  1. Sign in to Dynamics 365 and open the Connected Field Service app.

  2. In Connected Field Service, go to the Settings area.

  3. Select Providers, and then select New.

  4. Enter the following information:

    Screenshot of a new IoT Hub provider instance with sample data.

    • Name: The name of the resource group in Azure where you deployed IoT resources
    • IoT Provider: The IoT provider for IoT Hub
    • Provider Instance Id: The name of the IoT Hub resource that you deployed to your resource group in Azure
    • URL: The URL of the overview for the resource group in the Azure portal; for example, https://portal.azure.com/[tenant_id]/subscriptions/[subscription_id]/resourceGroups/[resource_group_name]/overview.
  5. Select Save.

Update the settings for the new provider instance.

  1. In the Settings area, select IoT Settings > IoT Provider Settings.

    Screenshot of the IoT Settings page.

  2. For Default IoT Provider, select the IoT provider instance you created.

  3. Select Save & Close.

  4. For a later step, find the IoT Provider Instance row in the msdyn_iotproviderinstance table and copy the GUID.

Set up an IoT endpoint

For this step, you need to know the hostname for the Service Bus Namespace deployed to your resource group.

  1. Download the Power Platform CLI and install it.

  2. Open the CLI and launch the Plugin Registration Tool (PRT) using the command pac tool prt.

  3. In the PRT window, select Create New Connection.

  4. In Display list of available organizations, select Office 365.

  5. Select Display list of available organizations, and then select Show Advanced.

  6. Select the region of your Field Service environment, enter your Field Service credentials, and then select Login.

    If you have access to multiple Dynamics 365 organizations, select the name of the org you want to work with.

Update the IoT Message service endpoint.

  1. After you're connected to the organization, find and select the IoT Message Service Endpoint.

  2. Select Update.

  3. For NameSpace Address, enter the hostname of the Service Bus Namespace in the Plug-in Registration Tool, prefixed by sb://; for example, sb://myServiceBusNamespace.servicebus.windows.net.

  4. In the Service Bus Namespace resource, go to Queues and find the queue with a name ending in -crm. Copy the full name and enter it as the Topic Name in the Plug-in Registration Tool.

  5. For Message Format, choose XML.

  6. In the Service Bus Namespace resource, go to Shared access policies > RootManageSharedAccessKey.

  7. Copy the name and paste it in SaS Key Name.

  8. Copy the primary key and paste it in SAS Key.

  9. Select Save.

    Screenshot of the Service Endpoint Registration page.

Authorize the Azure app connection

  1. Sign in to your Azure account and go to the Azure portal.

  2. Go to Resource Groups and find the resource group you deployed IoT Hub to.

  3. Select and edit the API Connection resource commondataservice.

  4. Under General, select Edit API Connection, and then select Authorize.

  5. Sign in with the Dynamics 365 credentials that you use to sign in to your Connected Field Service environment.

    They might be different from the credentials you use to sign in to the Azure portal.

  6. Select Save.

Update devicerules.json

The Stream Analytics job deployed to your resource group refers to a file named devicerules.json. This file defines a rule that creates IoT Alerts.

To use the rule, upload the devicerules.json file. You must reproduce the exact directory structure for the sample alert to work.

  1. Download the devicerules.json file from the GitHub repo.

  2. Open the resource group in the Azure admin portal and select the storage account deployed to your resource group.

  3. Select Containers, and then create a container called devicerules.

  4. Open the new container devicerules and select Upload.

  5. Browse to and select devicerules.json.

  6. Expand the Advanced section. In the Upload to folder field, enter 2016-05-30, and then select Upload.

  7. Open the new folder 2016-05-30 and select Upload.

  8. Browse to and select devicerules.json.

  9. Expand the Advanced section. In the Upload to folder field, enter 22-40, and then select Upload.

Start the Azure Stream Analytics jobs

  1. In the Azure portal, go to Resource Groups and find the resource group you deployed IoT Hub to.

  2. Select each Stream Analytics job and from the Overview tab, select Start.

You're ready to pass data between Azure IoT Hub and Dynamics 365 to use Connected Field Service.

Next steps