您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

教程:在 Azure IoT Central 中创建水质监测应用程序Tutorial: Create a water quality monitoring application in Azure IoT Central

本教程将为你提供分步指导,帮助你在 Azure IoT Central 中创建水质监测应用程序。This tutorial guides you through the creation of a water quality monitoring application in Azure IoT Central. 可从 Azure IoT Central 水质监测应用程序模板创建应用程序 。You create the application from the Azure IoT Central Water quality monitoring application template.

在本教程中,学习:In this tutorial, you learn to:

  • 使用水质监测模板来创建水质监测应用程序 。Use the Water quality monitoring template to create a water quality monitoring application.
  • 浏览并自定义操作员仪表板。Explore and customize an operator dashboard.
  • 浏览水质监测设备模板。Explore a water quality monitoring device template.
  • 浏览模拟设备。Explore simulated devices.
  • 浏览并配置规则。Explore and configure rules.
  • 配置作业。Configure jobs.
  • 使用白色标签自定义应用程序品牌。Customize application branding by using white labeling.

先决条件Prerequisites

建议你获取一个 Azure 订阅以完成本教程。We recommend that you have an Azure subscription to complete this tutorial. 如果没有 Azure 订阅,则可在 Azure 注册页上创建一个。If you don't have an Azure subscription, you can create one on the Azure sign-up page.

在 Azure IoT Central 中创建水质监测应用程序Create a water quality monitoring application in Azure IoT Central

在本节中,你将使用 Azure IoT Central 水质监测模板来创建水质监测应用程序 。In this section, you use the Azure IoT Central Water quality monitoring template to create a water quality monitoring application.

  1. 请转到 Azure IoT Central 主页Go to the Azure IoT Central home page.

    如果你有一个 Azure 订阅,请使用用于访问该订阅的凭据登录。If you have an Azure subscription, sign in with the credentials you use to access it. 否则,请使用 Microsoft 帐户登录:Otherwise, sign in with a Microsoft account:

    登录到你的组织帐户

  2. 选择 Azure IoT Central 最左侧窗格上的“生成”,然后选择“政府”选项卡 。“政府”窗格显示了一系列政府应用程序模板。Select Build on the leftmost pane of Azure IoT Central and select the Government tab. The government pane shows several government application templates.

    政府应用程序模板

  3. 选择“水质监测” 应用程序模板。Select the Water quality monitoring application template. 此应用程序模板包括水质设备模板、模拟设备、操作员仪表板以及预配置的监视规则。This application template includes a water quality device template, simulated devices, an operator dashboard, and preconfigured monitoring rules.

  4. 选择“创建应用” 。Select Create app. “新建应用程序”窗格将打开,并显示以下元素 :The New application pane opens and shows the following elements:

    • 应用程序名称:默认情况下,应用程序名称为“水质监测”,后跟 Azure IoT Central 生成的唯一 ID 字符串 。Application name: By default, the application name is Water quality monitoring followed by a unique ID string that Azure IoT Central generates. 如果需要,可以输入显示名称,也可以稍后更改应用程序名称。If you want, you can enter a display name or change the application name later.
    • URL:可以输入所需的任何 URL,也可以稍后更改 URL 值。URL: You can enter any URL you want or change the URL value later.
    • 如果你有一个 Azure 订阅,请输入目录、Azure 订阅和位置的值 。If you have an Azure subscription, enter values for Directory, Azure subscription, and Location. 如果你没有订阅,则可以启用 7 天免费试用版并填写所需的联系人信息 。If you don't have a subscription, you can turn on 7-day free trial and complete the required contact information.
  5. 选择页面左下方的“创建”按钮 。Select the Create button on the lower-left part of the page.

    Azure IoT Central 新建应用程序页

    Azure IoT Central 新建应用程序 - 计费信息

现已通过使用 Azure IoT Central 水质监测模板创建了一个水质监测应用程序 。You've now created a water quality monitoring application by using the Azure IoT Central Water quality monitoring template.

新应用程序附带以下预配置组件:Your new application comes with these preconfigured components:

  • 操作员仪表板Operator dashboards
  • 水质监测设备模板Water quality monitoring device templates
  • 模拟水质监测设备Simulated water quality monitoring devices
  • 规则和作业Rules and jobs
  • 使用白色标签的品牌Branding that uses white labeling

可随时修改应用程序。You can modify your application at any time.

接下来,浏览应用程序并进行一些自定义。Next, explore the application and make some customizations.

浏览和自定义操作员仪表板Explore and customize the operator dashboard

创建应用程序后,“Wide World 水质仪表板”窗格将打开 。After you create the application, the Wide World water quality dashboard pane opens.

水质监测仪表板

生成人员可在仪表板上创建和自定义视图,以供操作员使用。As a builder, you can create and customize views on the dashboard for use by operators. 但在尝试自定义之前,请先浏览仪表板。But before you try to customize, first explore the dashboard.

仪表板中显示的所有数据均基于模拟设备数据,这将在下节中进行讨论。All data shown in the dashboard is based on simulated device data, which is discussed in the next section.

该仪表板包含以下种类的磁贴:The dashboard includes the following kinds of tiles:

  • Wide World 供水公司图像磁贴:仪表板左上角的第一个磁贴是一个显示名为 Wide World 的虚构供水公司的图像。Wide World water utility image tile: The first tile in the upper-left corner of the dashboard is an image that shows the fictitious utility named Wide World. 可以自定义磁贴以使用自己的图像,也可以删除该磁贴。You can customize the tile to use your own image, or you can remove the tile.

  • 平均 pH KPI 磁贴:“过去 30 分钟内的平均 pH”等 KPI 磁贴位于仪表板窗格的顶部 。Average pH KPI tiles: KPI tiles like Average pH in the last 30 minutes are at the top of the dashboard pane. 可以自定义 KPI 磁贴,并将每个磁贴设置为不同的类型和时间范围。You can customize KPI tiles and set each to a different type and time range.

  • 水监测地区地图:Azure IoT Central 使用 Azure Maps,你可以在应用程序中直接对其进行设置以显示设备位置。Water monitoring area map: Azure IoT Central uses Azure Maps, which you can directly set in your application to show device location. 还可以将位置信息从应用程序映射到设备,然后使用 Azure Maps 显示地图上的信息。You can also map location information from your application to your device and then use Azure Maps to show the information on a map. 将鼠标悬停在地图上,并尝试使用控件。Hover over the map and try the controls.

  • 平均 pH 分布热图图表:可选择不同的可视化图表,以最适合你应用程序的方式显示设备遥测数据。Average pH distribution heat-map chart: You can select different visualization charts to show device telemetry in the way that is most appropriate for your application.

  • 关键质量指标折线图:可将一定时间范围内的设备遥测数据可视化为折线图。Critical quality indicators line chart: You can visualize device telemetry plotted as a line chart over a time range.

  • 化学制剂浓度条形图:可在条形图中可视化设备遥测数据。Concentration of chemical agents bar chart: You can visualize device telemetry in a bar chart.

  • 重置传感器参数磁贴:仪表板包含操作磁贴,操作员可直接从监视仪表板启动这些操作。Reset sensors parameters tile: The dashboard includes a tile for actions that an operator can initiate directly from the monitoring dashboard. 此类操作的一个示例是重置设备属性。Resetting a device's properties is an example of such actions.

  • 属性列表磁贴:仪表板具有多个属性磁贴,它们表示阈值信息、设备运行状况信息以及维护信息。Property list tiles: The dashboard has multiple property tiles that represent threshold information, device health information, and maintenance information.

自定义仪表板Customize the dashboard

生成人员可以自定义仪表板上的视图,以供操作员使用。As a builder, you can customize views on the dashboard for use by operators.

  1. 选择“编辑”可自定义“Wide World 水质仪表板”窗格 。Select Edit to customize the Wide World water quality dashboard pane. 可通过选择“编辑”菜单上的命令来自定义仪表板 。You can customize the dashboard by selecting commands on the Edit menu. 仪表板进入编辑模式后,可添加新的磁贴,也可配置现有文件。After the dashboard is in edit mode, you can add new tiles, or you can configure the existing files.

    编辑仪表板

  2. 选择“+ 新建”可以创建可配置的新仪表板 。Select + New to create a new dashboard that you can configure. 可以有多个仪表板,并且可以从仪表板菜单中进行导航。You can have multiple dashboards and can navigate among them from the dashboard menu.

浏览水质监测设备模板Explore a water quality monitoring device template

Azure IoT Central 中的设备模板定义了设备的功能。A device template in Azure IoT Central defines the capabilities of a device. 可用功能包括遥测、属性和命令。Available capabilities are telemetry, properties, and commands. 生成人员可在 Azure IoT Central 中定义表示所连接设备功能的设备模板。As a builder, you can define device templates in Azure IoT Central that represent the capabilities of the connected devices. 还可以创建模拟设备以测试设备模板和应用程序。You can also create simulated devices to test your device template and application.

已创建的水质监测应用程序附带一个水质监测设备模板。The water quality monitoring application you created comes with a water quality monitoring device template.

如需查看设备模板:To view the device template:

  1. 选择 Azure IoT Central 中应用程序最左侧窗格上的“设备模板” 。Select Device templates on the leftmost pane of your application in Azure IoT Central.

  2. 在设备模板列表中,选择“水质监测器”来打开该设备模板。From the list of device templates, select Water Quality Monitor to open that device template.

    设备模板

自定义设备模板Customize the device template

练习自定义以下设备模板设置:Practice customizing the following device template settings:

  1. 在设备模板菜单中,选择“自定义” 。From the device template menu, select Customize.
  2. 转到“温度”遥测类型 。Go to the Temperature telemetry type.
  3. 将“显示名称”值更改为“报告的温度” 。Change the Display name value to Reported temperature.
  4. 更改度量单位,或设置最小值和最大值 。Change the unit of measurement, or set Min value and Max value.
  5. 选择“保存”。 Select Save.

添加云属性Add a cloud property

  1. 从设备模板菜单中,选择“云属性”。From the device template menu, select Cloud properties.
  2. 若要添加新的云属性,请选择“+ 添加云属性” 。To add a new cloud property, select + Add Cloud Property. 在 Azure IoT Central 中,可以添加与设备相关但不应由设备发送的属性。In Azure IoT Central, you can add a property that is relevant to a device but not expected to be sent by the device. 此类属性的一个示例是特定于安装区域、资产信息或维护信息的警报阈值。One example of such a property is an alert threshold specific to installation area, asset information, or maintenance information.
  3. 输入“安装区域”作为显示名称,并选择“字符串”作为架构 。Enter Installation area as the Display name and choose String as the Schema.
  4. 选择“保存”。 Select Save.

浏览视图Explore views

水质监测设备模板附带预定义的视图。The water quality monitoring device template comes with predefined views. 视图定义操作员查看设备数据及设置云属性的方式。The views define how operators see the device data and set cloud properties. 浏览视图并练习更改。Explore the views and practice making changes.

设备模板视图

发布设备模板Publish the device template

如果进行了任何更改,请务必选择“发布”,以发布设备模板 。If you make any changes, be sure to select Publish to publish the device template.

创建新设备模板Create a new device template

  1. 在“设备模板”页面上,选择“+新建”来创建新的设备模板,然后执行创建过程 。On the Device templates page, select + New to create a new device template and follow the creation process.
  2. 创建自定义设备模板或从 Azure IoT 设备目录中选择设备模板。Create a custom device template or choose a device template from the Azure IoT device catalog.

浏览模拟设备Explore simulated devices

从应用程序模板创建的水质监测应用程序具有两个模拟设备。The water quality monitoring application you created from the application template has two simulated devices. 这些设备会映射到水质监测设备模板。These devices map to the water quality monitoring device template.

查看设备View the devices

  1. 选择应用程序最左侧窗格上的“设备” 。Select Devices on the leftmost pane of your application.

    设备

  2. 选择一个模拟设备。Select one simulated device.

    选择设备 1

  3. 在“云属性”选项卡上,将酸性 (pH) 阈值从 8 更改为 9,然后选择“保存” 。On the Cloud Properties tab, change the Acidity (pH) threshold value from 8 to 9 and select Save.

  4. 浏览“设备属性”选项卡和“设备仪表板”选项卡 。Explore the Device Properties tab and the Device Dashboard tab.

备注

已从设备模板视图配置所有选项卡 。All tabs have been configured from Device template views.

添加新设备Add new devices

  1. 在“设备”选项卡上,选择“+ 新建”以添加新设备 。On the Devices tab, select + New to add a new device.
  2. 使用建议的“设备 ID”或输入自己的设备 ID。Use the suggested Device ID or enter your own. 也可为新设备输入设备名称。You can also enter a Device name for your new device.
  3. 选择“水质监测器”作为设备模板 。Select Water Quality Monitor as the Device template.
  4. 如果要创建模拟设备,请确保“模拟此设备”设置为“是” 。Make sure the Simulate this device is set to Yes if you want to create a simulated device.
  5. 选择“创建”。Select Create.

浏览并配置规则Explore and configure rules

在 Azure IoT Central 中,可创建自动监视设备遥测的规则。In Azure IoT Central, you can create rules that automatically monitor device telemetry. 当任一条件满足时,这些规则将触发操作。These rules trigger an action when any of their conditions are met. 发送电子邮件通知是其中一种可能的操作。One possible action is to send email notifications. 其他可能的操作包括 Power Automate 操作或将数据发送到其他服务的 Webhook 操作。Other possibilities include a Power Automate action or a webhook action to send data to other services.

已创建的水质监测应用程序具有两个预配置的规则。The water quality monitoring application you created has two preconfigured rules.

查看规则View rules

  1. 选择应用程序最左侧窗格上的“规则” 。Select Rules on the leftmost pane of your application.

    规则

  2. 选择“高 pH 警报”,它是应用程序中的一项预配置规则 。Select High pH alert, which is one of the preconfigured rules in the application.

    高 pH 预警规则

    高 pH 预警规则配置为检查大于 8 的酸性 (pH) 条件 。The High pH alert rule is configured to check the condition of acidity (pH) being greater than 8.

接下来,将电子邮件操作添加到规则:Next, add an email action to the rule:

  1. 选择“+ 电子邮件” 。Select + Email.
  2. 在“显示名称”框中,输入“高 pH 警报” 。In the Display name box, enter High pH alert.
  3. 在“收件人”框中,输入与你的 Azure IoT Central 帐户关联的电子邮件地址 。In the To box, enter the email address associated with your Azure IoT Central account.
  4. (可选)输入要包含在电子邮件文本中的注释。Optionally, enter a note to include in the text of the email.
  5. 选择“完成” ,完成操作。Select Done to complete the action.
  6. 将规则设置为“已启用”,然后选择“保存” 。Set the rule to Enabled and select Save.

满足配置条件后,你应该能在几分钟内收到电子邮件。Within a few minutes, you should receive email when the configured condition is met.

备注

每次满足条件后,应用程序都会发送电子邮件。The application sends email each time a condition is met. 为某个规则选择“禁用”,以停止接收来自该规则的自动电子邮件 。Select Disable for a rule to stop receiving automated email from that rule.

若要创建新规则,请在应用程序最左侧的窗格上选择“规则”,然后选择“+ 新建” 。To create a new rule, select Rules on the leftmost pane of your application and then select +New.

配置作业Configure jobs

使用 Azure IoT Central 作业,可以在多台设备上触发对设备或云属性的更新。With Azure IoT Central jobs, you can trigger updates to device or cloud properties on multiple devices. 还可以使用作业在多个设备上触发设备命令。You can also use jobs to trigger device commands on multiple devices. Azure IoT Central 将自动执行工作流。Azure IoT Central automates the workflow for you.

  1. 在应用程序最左侧的窗格上选择“作业” 。Select Jobs on the leftmost pane of your application.
  2. 选择“+新建作业”,并配置一个或多个作业。Select +New job and configure one or more jobs.

自定义应用程序Customize your application

构建者可以更改多个设置来自定义应用程序中的用户体验。As a builder, you can change several settings to customize the user experience in your application.

  1. 选择“管理” > “自定义应用程序” 。Select Administration > Customize your application.

  2. 在“报头徽标”下选择“更改”,选择作为徽标上传的图像 。Under Masthead logo, select Change to choose the image to upload as the logo.

  3. 在“浏览器图标”下,选择“更改”以选择在浏览器选项卡上显示的图像 。Under Browser icon, select Change to choose the image that appears on browser tabs.

  4. 在“浏览器颜色”下,可将默认值替换为 HTML 十六进制颜色代码 。Under Browser colors, you can replace the default values with HTML hexadecimal color codes.

    自定义应用程序

更新应用程序图像Update the application image

  1. 选择“管理” > “你的应用程序”。 Select Administration > Your application.

  2. 选择“更改”,来选择要上传用作应用程序图像的图像。Select Change to choose an image to upload as the application image.

清理资源Clean up resources

如果不打算继续使用应用程序,请删除应用程序,步骤如下:If you're not going to continue to use your application, delete the application with the following steps:

  1. 打开应用程序最左侧窗格上的“管理”选项卡 。Open the Administration tab on the leftmost pane of your application.

  2. 选择“你的应用程序”,然后选择“删除”按钮 。Select Your application and select the Delete button.

    删除应用程序

后续步骤Next steps

  • 详细了解以下内容Learn more about