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.
- Step 1: Deploy Connected Field Service and Azure resources from an ARM template
- Step 2: Create an IoT provider instance
- Step 3: Set up an IoT endpoint
- Step 4: Authorize the Azure app connection
- Step 5: Update devicerules.json
- Step 6: Start the Azure Stream Analytics jobs
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
You have the System Administrator and IoT Administrator security roles.
You have an active Azure subscription with privileges to create resources and services.
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.
Select Deploy to Azure on the page https://github.com/microsoft/Dynamics-365-Connected-Field-Service-Deployment.
Select your Azure subscription.
Select a resource group or create one.
Set the region to the same region as your Field Service environment.
Enter the unique name of your organization and the organization URL of the Field Service environment.
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.
Select Review + create.
Make sure the deployment is complete before you proceed.
Create an IoT provider instance
Sign in to Dynamics 365 and open the Connected Field Service app.
In Connected Field Service, go to the Settings area.
Select Providers, and then select New.
Enter the following information:
- 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
.
Select Save.
Update the settings for the new provider instance.
In the Settings area, select IoT Settings > IoT Provider Settings.
For Default IoT Provider, select the IoT provider instance you created.
Select Save & Close.
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.
Download the Power Platform CLI and install it.
Open the CLI and launch the Plugin Registration Tool (PRT) using the command
pac tool prt
.In the PRT window, select Create New Connection.
In Display list of available organizations, select Office 365.
Select Display list of available organizations, and then select Show Advanced.
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.
After you're connected to the organization, find and select the IoT Message Service Endpoint.
Select Update.
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
.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.For Message Format, choose XML.
In the Service Bus Namespace resource, go to Shared access policies > RootManageSharedAccessKey.
Copy the name and paste it in SaS Key Name.
Copy the primary key and paste it in SAS Key.
Select Save.
Authorize the Azure app connection
Sign in to your Azure account and go to the Azure portal.
Go to Resource Groups and find the resource group you deployed IoT Hub to.
Select and edit the API Connection resource commondataservice.
Under General, select Edit API Connection, and then select Authorize.
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.
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.
Download the
devicerules.json
file from the GitHub repo.Open the resource group in the Azure admin portal and select the storage account deployed to your resource group.
Select Containers, and then create a container called
devicerules
.Open the new container
devicerules
and select Upload.Browse to and select
devicerules.json
.Expand the Advanced section. In the Upload to folder field, enter 2016-05-30, and then select Upload.
Open the new folder
2016-05-30
and select Upload.Browse to and select
devicerules.json
.Expand the Advanced section. In the Upload to folder field, enter 22-40, and then select Upload.
Start the Azure Stream Analytics jobs
In the Azure portal, go to Resource Groups and find the resource group you deployed IoT Hub to.
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.