MR 和 Azure 313:IoT 中心服务MR and Azure 313: IoT Hub Service

备注

混合现实学院教程在制作时考虑到了 HoloLens(第一代)和混合现实沉浸式头戴显示设备。The Mixed Reality Academy tutorials were designed with HoloLens (1st gen) and Mixed Reality Immersive Headsets in mind. 因此,对于仍在寻求这些设备的开发指导的开发人员而言,我们觉得很有必要保留这些教程。As such, we feel it is important to leave these tutorials in place for developers who are still looking for guidance in developing for those devices. 我们 不会 在这些教程中更新 HoloLens 2 所用的最新工具集或集成相关的内容。These tutorials will not be updated with the latest toolsets or interactions being used for HoloLens 2. 我们将维护这些教程,使之持续适用于支持的设备。They will be maintained to continue working on the supported devices. 将来会发布一系列新教程,这些教程将演示如何针对 HoloLens 2 进行开发。There will be a new series of tutorials that will be posted in the future that will demonstrate how to develop for HoloLens 2. 此通知将在发布时通过指向这些教程的链接进行更新。This notice will be updated with a link to those tutorials when they are posted.

课程结果

在本课程中,你将了解如何在运行 Ubuntu 16.4 操作系统的虚拟机上实现 Azure IoT 中心服务In this course, you will learn how to implement an Azure IoT Hub Service on a virtual machine running the Ubuntu 16.4 operating system. 然后, azure Function App 将用于从 Ubuntu VM 接收消息,并将结果存储在 Azure 表服务 中。An Azure Function App will then be used to receive messages from your Ubuntu VM, and store the result within an Azure Table Service. 然后,你将能够使用 Microsoft HoloLens 上的 Power BI 或沉浸式 (VR) 耳机查看此数据。You will then be able to view this data using Power BI on Microsoft HoloLens or immersive (VR) headset.

本课程的内容 适用 于 IoT Edge 设备,不过,在本课程中,重点将位于虚拟机环境中,因此不需要访问物理边缘设备。The content of this course is applicable to IoT Edge devices, though for the purpose of this course, the focus will be on a virtual machine environment, so that access to a physical Edge device is not necessary.

完成本课程后,你将学习:By completing this course, you will learn to:

  • IoT Edge 模块 部署到 (UBUNTU 16 OS) 虚拟机,这将表示 IoT 设备。Deploy an IoT Edge module to a Virtual Machine (Ubuntu 16 OS), which will represent your IoT device.
  • Azure 自定义视觉 Tensorflow 模型 添加到 Edge 模块,其中包含用于分析容器中存储的图像的代码。Add an Azure Custom Vision Tensorflow Model to the Edge module, with code that will analyze images stored in the container.
  • 设置模块以将分析结果消息发送回 IoT 中心服务Set up the module to send the analysis result message back to your IoT Hub Service.
  • 使用 azure Function App 将消息存储在 azure 表 中。Use an Azure Function App to store the message within an Azure Table.
  • 设置 Power BI 以收集存储的消息并创建报表。Set up Power BI to collect the stored message and create a report.
  • Power BI 中直观显示 IoT 消息数据。Visualize your IoT message data within Power BI.

将使用的服务包括:The Services you will use include:

  • Azure IoT 中心 是一种 Microsoft Azure 服务,它允许开发人员连接、监视和管理 IoT 资产。Azure IoT Hub is a Microsoft Azure Service which allows developers to connect, monitor, and manage, IoT assets. 有关详细信息,请访问 Azure IoT 中心服务For more information, visit the Azure IoT Hub Service page.

  • Azure 容器注册表 是一种 Microsoft Azure 服务,它允许开发人员为各种类型的容器存储容器映像。Azure Container Registry is a Microsoft Azure Service which allows developers to store container images, for various types of containers. 有关详细信息,请访问 Azure 容器注册表服务For more information, visit the Azure Container Registry Service page.

  • Azure Function App 是一种 Microsoft Azure 服务,它允许开发人员在 Azure 中运行小部分代码 "函数"。Azure Function App is a Microsoft Azure Service, which allows developers to run small pieces of code, 'functions', in Azure. 这提供了一种方法,可将工作委托给云,而不是本地应用程序,这可能有很多好处。This provides a way to delegate work to the cloud, rather than your local application, which can have many benefits. Azure Functions 支持多种开发语言,包括 C # 、F # 、Node.js、Java 和 PHP。Azure Functions supports several development languages, including C#, F#, Node.js, Java, and PHP. 有关详细信息,请访问 Azure FunctionsFor more information, visit the Azure Functions page.

  • Azure 存储:表 是一项 Microsoft Azure 服务,它允许开发人员在云中存储结构化非 SQL 数据,使其在任何位置轻松访问。Azure Storage: Tables is a Microsoft Azure Service, which allows developers to store structured, non-SQL, data in the cloud, making it easily accessible anywhere. 此服务的设计良好,可根据需要进行表的发展,因此非常灵活。The Service boasts a schema-less design, allowing for the evolution of tables as needed, and thus is very flexible. 有关详细信息,请访问 Azure 表For more information, visit the Azure Tables page

本课程将介绍如何设置和使用 IoT 中心服务,然后将设备提供的响应可视化。This course will teach you how to setup and use the IoT Hub Service, and then visualize a response provided by a device. 您可以将这些概念应用到您可能会构建的自定义 IoT 中心服务设置。It will be up to you to apply these concepts to a custom IoT Hub Service setup, which you might be building.

设备支持Device support

课程Course HoloLensHoloLens 沉浸式头戴显示设备Immersive headsets
MR 和 Azure 313:IoT 中心服务MR and Azure 313: IoT Hub Service ✔️✔️ ✔️✔️

先决条件Prerequisites

有关利用混合现实进行开发的最新先决条件,包括 Microsoft HoloLens,请访问 安装工具 一文。For the most up-to-date prerequisites for developing with mixed reality, including with the Microsoft HoloLens, visit the Install the tools article.

备注

本教程适用于具有 Python 的基本经验的开发人员。This tutorial is designed for developers who have basic experience with Python. 请注意,本文档中的先决条件和书面说明表示在) 2018 年7月 (撰写本文时已测试和验证的内容。Please also be aware that the prerequisites and written instructions within this document represent what has been tested and verified at the time of writing (July 2018). 您可以随意使用最新的软件(如 安装工具 一文中所述),但不应假定本课程中的信息将与下面列出的软件内容完全匹配。You are free to use the latest software, as listed within the install the tools article, though it should not be assumed that the information in this course will perfectly match what you will find in newer software than that listed below.

需要以下硬件和软件:The following hardware and software is required:

准备工作Before you start

  1. 设置并测试你的 HoloLens。Set up and test your HoloLens. 如果需要支持设置 HoloLens,请 确保访问 hololens 设置一文If you need support setting up your HoloLens, make sure to visit the HoloLens setup article.
  2. 在开始开发新的 HoloLens 应用程序时,最好执行 校准传感器调整 (有时,它可以帮助为每个用户) 执行这些任务。It is a good idea to perform Calibration and Sensor Tuning when beginning developing a new HoloLens app (sometimes it can help to perform those tasks for each user).

有关校准的帮助信息,请单击此链接,了解 到 HoloLens 校准文章For help on Calibration, please follow this link to the HoloLens Calibration article.

有关传感器优化的帮助,请单击 "HoloLens 传感器优化" 一文For help on Sensor Tuning, please follow this link to the HoloLens Sensor Tuning article.

  1. 使用 hyper-v 设置 Ubuntu 虚拟机Set up your Ubuntu Virtual Machine using Hyper-V. 以下资源将帮助你执行此过程。The following resources will help you with the process.

    1. 首先,请单击以下链接 下载 Ubuntu 16.04.4 LTS (Xenial Xerus) ISOFirst, follow this link to download the Ubuntu 16.04.4 LTS (Xenial Xerus) ISO. 选择 64 (AMD64) 桌面映像Select the 64-bit PC (AMD64) desktop image.
    2. 请确保已在 Windows 10 计算机上启用 hyper-vMake sure Hyper-V is enabled on your Windows 10 machine. 你可以访问此链接以获取有关在 Windows 10 上安装和启用 hyper-v的指南。You can follow this link for guidance on installing and enabling Hyper-V on Windows 10.
    3. 启动 Hyper-v 并创建新的 Ubuntu VM。Start Hyper-V and create a new Ubuntu VM. 可以访问此链接,了解有关 如何使用 hyper-v 创建 VM的分步指导。You can follow this link for a step by step guide on how to create a VM with Hyper-V. 当请求 "从可启动的映像文件安装操作系统" 时,选择之前下载的 Ubuntu ISOWhen requested to "Install an operating system from a bootable image file", select the Ubuntu ISO you have download earlier.

    备注

    不建议使用 Hyper-v 快速创建Using Hyper-V Quick Create is not suggested.

第1章-检索自定义视觉模型Chapter 1 - Retrieve the Custom Vision model

在本课程中,您将有权访问 预建的自定义视觉模型 ,用于检测图像中的键盘和鼠标。With this course you will have access to a pre-built Custom Vision model that detects keyboards and mice from images. 如果使用此操作,请转到 第2章If you use this, proceed to Chapter 2.

但是,如果想要使用自己的自定义视觉模型,则可以执行以下步骤:However, you can follow these steps if you wish to use your own Custom Vision model:

  1. 自定义视觉项目 中转到 " 性能 " 选项卡。In your Custom Vision Project go to the Performance tab.

    警告

    您的模型必须使用 精简 域来导出模型。Your model must use a compact domain, to export the model. 你可以在项目的设置中更改模型域。You can change your models domain in the settings for your project.

    性能选项卡

  2. 选择要导出的 迭代 ,并单击 " 导出"。Select the Iteration you want to export and click on Export. 随即出现一个边栏选项卡。A blade will appear.

    导出边栏选项卡

  3. 在边栏选项卡中,单击 " Docker 文件"。In the blade click Docker File.

    选择 docker

  4. 在下拉菜单中单击 " Linux ",然后单击 " 下载"。Click Linux in the drop-down menu and then click on Download.

    单击 "下载"

  5. 解压缩内容。Unzip the content. 稍后将在本课程中使用它。You will use it later in this course.

第2章-容器注册表服务Chapter 2 - The Container Registry Service

容器注册表服务 是用于托管容器的存储库。The Container Registry Service is the repository used to host your containers.

你将在本课程中构建和使用的 IoT 中心服务 是指 容器注册表服务 ,用于获取要在边缘设备中部署的容器。The IoT Hub Service that you will build and use in this course, refers to Container Registry Service to obtain the containers to deploy in your Edge Device.

  1. 首先,请 在 Azure 门户中单击此链接,然后用你的凭据登录。First, follow this link to the Azure Portal, and login with your credentials.

  2. 请参阅 创建资源 并查找 容器注册表Go to Create a resource and look for Container Registry.

    容器注册表

  3. 单击 " 创建"。Click on Create.

  4. 设置服务安装参数:Set the Service setup parameters:

    1. 插入项目的名称,在本示例中,它称为 IoTCRegistryInsert a name for your project, In this example its called IoTCRegistry.

    2. 选择一个 资源组 ,或创建一个新的资源组。Choose a Resource Group or create a new one. 资源组提供一种方式来监视、控制访问、预配和管理 Azure 资产集合的计费。A resource group provides a way to monitor, control access, provision, and manage, billing for a collection of Azure assets. 建议保留与单个项目关联的所有 Azure 服务 (例如,这些课程) 常用资源组) 下。It is recommended to keep all the Azure Services associated with a single project (e.g. such as these courses) under a common resource group).

    3. 设置服务的位置。Set the location of the Service.

    4. 将 " 管理员用户 " 设置为 启用Set Admin user to Enable.

    5. SKU 设置为 基本Set SKU to Basic.

  5. 单击 " 创建 " 并等待要创建的服务。Click Create and wait for the Services to be created.

  6. 通知进入成功创建 容器注册表 后,请单击 " 转到资源 ",将其重定向到 "服务" 页。Once the notification pops up informing you of the successful creation of the Container Registry, click on Go to resource to be redirected to your Service page.

  7. 在 " 容器注册表 服务" 页上,单击 " 访问密钥"。In the Container Registry Service page, click on Access keys.

  8. 请注意 (可以使用以下参数的记事本) :Take note (you could use your Notepad) of the following parameters:

    1. 登录服务器Login Server
    2. 用户名Username
    3. 密码Password

第3章-IoT 中心服务Chapter 3 - The IoT Hub Service

现在,你将开始创建和设置 IoT 中心服务Now you will begin the creation and setup of your IoT Hub Service.

  1. 如果尚未登录,请登录到 Azure 门户If not already signed in, log into the Azure Portal.

  2. 登录后,单击左上角的 " 创建资源 ",搜索 " IoT 中心",然后单击 " Enter"。Once logged in, click on Create a resource in the top left corner, and search for IoT Hub, and click Enter.

搜索存储帐户

  1. 新页将提供 存储帐户 服务的说明。The new page will provide a description of the Storage account Service. 在此提示符的左下方,单击 " 创建 " 按钮以创建此服务的实例。At the bottom left of this prompt, click the Create button, to create an instance of this Service.

    创建存储实例

  2. 单击 " 创建" 后,将显示一个面板:Once you have clicked on Create, a panel will appear:

    1. 选择一个 资源组 ,或创建一个新的资源组。Choose a Resource Group or create a new one. 资源组提供一种监视、控制访问、预配和管理 Azure 资产集合的计费的方法。A resource group provides a way to monitor, control access, provision and manage billing for a collection of Azure assets. 建议保留与单个项目关联的所有 Azure 服务 (例如,这些课程) 常用资源组) 下。It is recommended to keep all the Azure Services associated with a single project (e.g. such as these courses) under a common resource group).

      如果希望了解有关 Azure 资源组的详细信息,请参阅此 链接,了解如何管理资源组If you wish to read more about Azure Resource Groups, please follow this link on how to manage a Resource Group.

    2. 选择适当的 位置 (在本课程中创建的所有服务中使用同一位置) 。Select an appropriate Location (Use the same location across all the Services you create in this course).

    3. 为此服务实例插入所需的 名称Insert your desired Name for this Service instance.

  3. 在页面底部,单击 " 下一步:大小和缩放"。On the bottom of the page click on Next: Size and scale.

    创建存储实例

  4. 在此页中,选择你的 定价和缩放层 (如果这是你的第一个 IoT 中心服务实例,则你) 应提供一个免费级别。In this page, select your Pricing and scale tier (if this is your first IoT Hub Service instance, a free tier should be available to you).

  5. 单击 " 查看" + "创建"。Click on Review + Create.

    创建存储实例

  6. 查看设置,然后单击 " 创建"。Review your settings and click on Create.

    创建存储实例

  7. 通知进入成功创建 IoT 中心 服务的通知后,请单击 " 转到资源 ",将其重定向到 "服务" 页。Once the notification pops up informing you of the successful creation of the IoT Hub Service, click on Go to resource to be redirected to your Service page.

    创建存储实例

  8. 滚动到左侧的侧面板,直到看到 " 自动设备管理",然后单击 " IoT Edge"。Scroll the side panel on the left until you see Automatic Device Management, the click on IoT Edge.

    创建存储实例

  9. 在出现在右侧的窗口中,单击 " 添加 IoT Edge 设备"。In the window that appears to the right, click on Add IoT Edge Device. 边栏选项卡将显示在右侧。A blade will appear to the right.

  10. 在边栏选项卡中,提供新设备的 设备 ID (所选) 的名称。In the blade, provide your new device a Device ID (a name of your choice). 然后,单击“保存”。Then, click Save. 如果已 自动生成 勾选,则 主密钥辅助密钥 将自动生成。The Primary and Secondary Keys will auto generate, if you have Auto Generate ticked.

    创建存储实例

  11. 你将导航回 IoT Edge 设备 "部分,将在其中列出新设备。You will navigate back to the IoT Edge Devices section, where your new device will be listed. 单击下图中以红色列出的新设备 () 。Click on your new device (outlined in red in the below image).

    创建存储实例

  12. 在出现的 " 设备详细信息 " 页上,获取 连接字符串 (主键) 的副本。On the Device Details page that appears, take a copy of the Connection String (primary key).

    创建存储实例

  13. 返回到左侧的面板,单击 " 共享访问策略" 将其打开。Go back to the panel on the left, and click Shared access policies, to open it.

  14. 在显示的页面上,单击 " iothubowner",屏幕右侧会显示一个边栏选项卡。On the page that appears, click iothubowner, and a blade will appear to the right of the screen.

  15. 请注意 (在记事本) 的 连接字符串 (主键) ,以便以后在将 连接字符串 设置到设备时使用。Take note (on your Notepad) of the Connection string (primary key), for later use when setting the Connection String to your device.

    创建存储实例

第4章-设置开发环境Chapter 4 - Setting up the development environment

若要为 IoT 中心边缘 创建和部署模块,需要在运行 Windows 10 的开发计算机上安装以下组件:In order to create and deploy modules for IoT Hub Edge, you will require the following components installed on your development machine running Windows 10:

  1. 用于 Windows 的 Docker,它将要求你创建一个可供下载的帐户。Docker for Windows, it will ask you to create an account to be able to download.

    下载适用于 windows 的 dockerdownload docker for windows

    重要

    Docker 需要 windows 10 专业**版、企业版 14393windows Server 2016 RTM 才能运行。Docker requires Windows 10 PRO, Enterprise 14393, or Windows Server 2016 RTM, to run. 如果你运行的是其他版本的 Windows 10,则可以尝试使用 Docker 工具箱安装 docker。If you are running other versions of Windows 10, you can try installing Docker using the Docker Toolbox.

  2. Python 3.6Python 3.6.

    下载 python 3。6download python 3.6

  3. Visual Studio Code (也称为 VS Code) Visual Studio Code (also known as VS Code).

    下载 VS Codedownload VS Code

安装上述软件之后,需要重新启动计算机。After installing the software mentioned above, you will need to restart your machine.

第5章-设置 Ubuntu 环境Chapter 5 - Setting up the Ubuntu environment

现在,可以转到设置 运行 UBUNTU 操作系统 的设备。Now you can move on to setting up your device running Ubuntu OS. 按照以下步骤安装所需的软件,以便在你的面板上部署容器:Follow the steps below, to install the necessary software, to deploy your containers on your board:

重要

应始终在带有 sudo 的终端命令之前,以管理员用户身份运行。You should always precede the terminal commands with sudo to run as admin user. i.e:

sudo docker \<option> \<command> \<argument>
  1. 打开 Ubuntu 终端,并使用以下命令安装 pipOpen the Ubuntu Terminal, and use the following command to install pip:

    [!提示] 可以使用键盘快捷方式轻松地打开 终端Ctrl + Alt + T[!HINT] You can open Terminal very easily through using the keyboard shortcut: Ctrl + Alt + T.

        sudo apt-get install python-pip
    
  2. 在本章中,系统可能会提示你: 终端,允许你使用设备存储,并输入 y/n ("是" 或 "否") ,键入 "y",然后按 enter 键接受。Throughout this Chapter, you may be prompted, by Terminal, for permission to use your device storage, and for you to input y/n (yes or no), type 'y', and then press the Enter key, to accept.

  3. 完成该命令后,请使用以下命令安装 Once that command has completed, use the following command to install curl:

        sudo apt install curl
    
  4. 安装 pip卷曲 后,使用以下命令安装 IoT Edge 运行时,这是部署和控制板上的模块所必需的:Once pip and curl are installed, use the following command to install the IoT Edge runtime, this is necessary to deploy and control the modules on your board:

        curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > ./microsoft-prod.list
    
        sudo cp ./microsoft-prod.list /etc/apt/sources.list.d/
    
        curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
    
        sudo cp ./microsoft.gpg /etc/apt/trusted.gpg.d/
    
        sudo apt-get update
    
        sudo apt-get install moby-engine
    
        sudo apt-get install moby-cli
    
        sudo apt-get update
    
        sudo apt-get install iotedge
    
  5. 此时,系统将提示你打开 运行时配置文件,以插入你记下的 设备连接字符串) (你记下的设备连接字符串,在创建 IoT 中心服务 (在第 3 章) 的步骤 14 中。At this point you will be prompted to open up the runtime config file, to insert the Device Connection String, that you noted down (in your Notepad), when creating the IoT Hub Service (at step 14, of Chapter 3). 在终端上运行以下行,以打开该文件:Run the following line on the terminal to open that file:

        sudo nano /etc/iotedge/config.yaml
    
  6. 此时将显示 yaml 文件,供你编辑:The config.yaml file will be displayed, ready for you to edit:

    警告

    打开此文件时,可能会有些混乱。When this file opens, it may be somewhat confusing. 你将在 终端 本身中编辑此文件的文本。You will be text editing this file, within the Terminal itself.

    1. 使用键盘上的箭头键向下滚动 (需要向下滚动一点) ,才能到达包含 ":Use the arrow keys on your keyboard to scroll down (you will need to scroll down a little way), to reach the line containing":

      "<ADD DEVICE CONNECTION STRING HERE>"."<ADD DEVICE CONNECTION STRING HERE>".

    2. 用前面记下的 设备连接字符串 替换线条(包括方括号)。Substitute line, including the brackets, with the Device Connection String you have noted earlier.

  7. 建立连接字符串后,请在键盘上按 Ctrl + X 键保存该文件。With your Connection String in place, on your keyboard, press the Ctrl-X keys to save the file. 它将要求通过键入 Y 进行确认。然后,按 enter 键以确认。It will ask you to confirm by typing Y. Then, press the Enter key, to confirm. 你将返回到常规 终端You will go back to the regular Terminal.

  8. 成功运行这些命令后,你将安装 IoT Edge 运行时Once these commands have all run successfully, you will have installed the IoT Edge Runtime. 初始化后,每次打开设备时,运行时就会自行启动,并将在后台等待从 IoT 中心服务 部署模块。Once initialized, the runtime will start on its own every time the device is powered up, and will sit in the background, waiting for modules to be deployed from the IoT Hub Service.

  9. 运行以下命令行,初始化 IoT Edge 运行时Run the following command line to initialize the IoT Edge Runtime:

        sudo systemctl restart iotedge
    

    重要

    如果更改了 yaml 文件或上述设置,则需要在 终端 内再次运行上面的重新启动行。If you make changes to your .yaml file, or the above setup, you will need to run the above restart line again, within Terminal.

  10. 通过运行以下命令行检查 IoT Edge 运行时 状态。Check the IoT Edge Runtime status by running the following command line. 运行时应显示状态为 active (以绿色文本 运行)The runtime should appear with the status active (running) in green text.

        sudo systemctl status iotedge
    
  11. 按下 Ctrl + C 键,退出 "状态" 页。Press the Ctrl-C keys, to exit the status page. 可以通过键入以下命令来验证 IoT Edge 运行时 是否正确拉取容器:You can verify that the IoT Edge Runtime is pulling the containers correctly by typing the following command:

        sudo docker ps
    
  12. 应显示具有两个 (2) 容器的列表。A list with two (2) containers should appear. 这些是 IoT 中心服务自动创建的默认模块 (edgeAgent 和 edgeHub) 。These are the default modules that are automatically created by the IoT Hub Service (edgeAgent and edgeHub). 一旦您创建和部署自己的模块,它们将显示在此列表中的默认值之下。Once you create and deploy your own modules, they will appear in this list, underneath the default ones.

第6章-安装扩展Chapter 6 - Install the extensions

重要

接下来的几章 (6-9) 在 Windows 10 计算机上执行。The next few Chapters (6-9) are to be performed on your Windows 10 machine.

  1. 打开 VS CodeOpen VS Code.

  2. 单击 VS Code 左侧栏) " (的" 扩展 ",打开" 扩展 "面板Click on the Extensions (square) button on the left bar of VS Code, to open the Extensions panel.

  3. 搜索并安装以下扩展 (如下图所示) :Search for, and install, the following extensions (as shown in the image below):

    1. Azure IoT EdgeAzure IoT Edge
    2. Azure IoT 工具包Azure IoT Toolkit
    3. DockerDocker

    创建容器

  4. 安装扩展后,请关闭并重新打开 VS Code。Once the extensions are installed, close and re-open VS Code.

  5. 再打开 VS Code,导航到 "查看" " > 集成终端"。With VS Code open once more, navigate to View > Integrated terminal.

  6. 现在,你将安装 CookiecutterYou will now install Cookiecutter. 在终端中运行以下 bash 命令:In the terminal run the following bash command:

        pip install --upgrade --user cookiecutter
    

    [!提示] 如果你在使用此命令时遇到问题:[!HINT] If you have trouble with this command:

    1. 重新启动 VS Code 和/或您的计算机。Restart VS Code, and/ or your computer.
    2. 可能需要将 VS Code 终端 切换到你用来安装 Python 的计算机(例如 Powershell (),尤其是在你的计算机上安装了 python 环境) 时。It might be necessary to switch the VS Code Terminal to the one you have been using to install Python, i.e. Powershell (especially in case the Python environment was already installed on your machine). 打开终端后,会在终端的右侧找到下拉菜单。With the Terminal open, you will find the drop down menu on the right side of the Terminal. 创建容器Create your container
    3. 请确保将 Python 安装路径添加为计算机上的 环境变量Make sure the Python installation path is added as Environment Variable on your machine. Cookiecutter 应属于同一位置路径。Cookiecutter should be part of the same location path. 有关环境变量的详细信息,请访问此链接Please follow this link for more information on Environment Variables,
  7. Cookiecutter 安装完成后,应重新启动计算机,以便在系统环境中将 Cookiecutter 识别为命令。Once Cookiecutter has finished installing, you should restart your machine, so that Cookiecutter is recognized as a command, within your System's environment.

第7章-创建容器解决方案Chapter 7 - Create your container solution

此时,需要创建包含模块的容器,将其推送到 容器注册表 中。At this point, you need to create the container, with the module, to be pushed into the Container Registry. 推送容器后,将使用 IoT 中心边缘 服务将其部署到运行 IoT Edge 运行时 的设备。Once you have pushed your container, you will use the IoT Hub Edge Service to deploy it to your device, which is running the IoT Edge runtime.

  1. 在 VS Code 中,单击 "查看" " > 命令面板"。From VS Code, click View > Command palette.

  2. 在调色板中,搜索并运行 Azure IoT Edge:新的 IoT Edge 解决方案In the palette, search and run Azure IoT Edge: New Iot Edge Solution.

  3. 浏览到要在其中创建解决方案的位置。Browse into a location where you want to create your solution. enter 键接受该位置。Press the Enter key, to accept the location.

  4. 为解决方案指定一个名称。Give a name to your solution. enter 键以确认所提供的名称。Press the Enter key, to confirm your provided name.

  5. 现在,系统将提示您选择解决方案的模板框架。Now you will be prompted to choose the template framework for your solution. 单击 " Python 模块"。Click Python Module. enter 键确认此选择。Press the Enter key, to confirm this choice.

  6. 为模块指定名称。Give a name to your module. enter 键以确认模块的名称。Press the Enter key, to confirm the name of your module. 请确保记下与你的记事本) (模块名称,因为稍后将用到它。Make sure to take a note (with your Notepad) of the module name, as it is used later.

  7. 你会注意到,组件面板上将显示预先生成的 Docker 映像存储库 地址。You will notice a pre-built Docker Image Repository address will appear on the palette. 它将如下所示:It will look like:

    localhost: 5000/-模块的名称-localhost:5000/-THE NAME OF YOUR MODULE-.

  8. 删除 localhost: 5000,并在其位置插入 容器注册表***登录服务器* 地址(在创建 容器注册表服务 时记下的), (第2章) 中的步骤 8Delete localhost:5000, and in its place insert the Container Registry Login Server address, which you noted when creating the Container Registry Service (in step 8, of Chapter 2). enter 键以确认地址。Press the Enter key, to confirm the address.

  9. 此时,将创建包含 Python 模块模板的解决方案,并将其结构显示在 "浏览" 选项卡的 " 浏览器" 选项卡 中,在 "浏览器" 选项卡中,在 "浏览器" 选项卡中,在 "VS CodeAt this point, the solution containing the template for your Python module will be created and its structure will be displayed in the Explore Tab, of VS Code, on the left side of the screen. 如果 " 资源管理器" 选项卡 未打开,则可以通过单击左侧栏中的最上面的按钮打开它。If the Explore Tab is not open, you can open it by clicking the top-most button, in the bar on the left.

    创建容器

  10. 本章的最后一个步骤是,从 "浏览" 选项卡 中单击并打开 " env" 文件,然后添加 容器注册表***用户名* 和 密码The last step for this Chapter, is to click and open the .env file, from within the Explore Tab, and add your Container Registry username and password. Git 忽略此文件,但在构建容器时,将设置用于访问 容器注册表服务 的凭据。This file is ignored by git, but on building the container, will set the credentials to access the Container Registry Service.

    创建容器

第8章-编辑容器解决方案Chapter 8 - Editing your container solution

现在,你将通过更新下列文件来完成容器解决方案:You will now complete the container solution, by updating the following files:

  • py python 脚本。main.py python script.
  • requirements.txtrequirements.txt.
  • deployment.template.jsdeployment.template.json.
  • Dockerfile amd64Dockerfile.amd64

然后,将创建用于 python 脚本的 images 文件夹, 以检查图像是否与 自定义视觉模型 匹配。You will then create the images folder, used by the python script to check for images to match against your Custom Vision model. 最后,您将添加 labels.txt 文件,以帮助读取 您的模型和模型文件。Lastly, you will add the labels.txt file, to help read your model, and the model.pb file, which is your model.

  1. 打开 VS Code,导航到模块文件夹,然后查找名为 py 的脚本。With VS Code open, navigate to your module folder, and look for the script called main.py. 双击将其打开。Double-click to open it.

  2. 删除文件的内容并插入以下代码:Delete the content of the file and insert the following code:

    # Copyright (c) Microsoft. All rights reserved.
    # Licensed under the MIT license. See LICENSE file in the project root for
    # full license information.
    
    import random
    import sched, time
    import sys
    import iothub_client
    from iothub_client import IoTHubModuleClient, IoTHubClientError, IoTHubTransportProvider
    from iothub_client import IoTHubMessage, IoTHubMessageDispositionResult, IoTHubError
    import json
    import os
    import tensorflow as tf
    import os
    from PIL import Image
    import numpy as np
    import cv2
    
    # messageTimeout - the maximum time in milliseconds until a message times out.
    # The timeout period starts at IoTHubModuleClient.send_event_async.
    # By default, messages do not expire.
    MESSAGE_TIMEOUT = 10000
    
    # global counters
    RECEIVE_CALLBACKS = 0
    SEND_CALLBACKS = 0
    
    TEMPERATURE_THRESHOLD = 25
    TWIN_CALLBACKS = 0
    
    # Choose HTTP, AMQP or MQTT as transport protocol.  Currently only MQTT is supported.
    PROTOCOL = IoTHubTransportProvider.MQTT
    
    
    # Callback received when the message that we're forwarding is processed.
    def send_confirmation_callback(message, result, user_context):
        global SEND_CALLBACKS
        print ( "Confirmation[%d] received for message with result = %s" % (user_context, result) )
        map_properties = message.properties()
        key_value_pair = map_properties.get_internals()
        print ( "    Properties: %s" % key_value_pair )
        SEND_CALLBACKS += 1
        print ( "    Total calls confirmed: %d" % SEND_CALLBACKS )
    
    
    def convert_to_opencv(image):
        # RGB -> BGR conversion is performed as well.
        r,g,b = np.array(image).T
        opencv_image = np.array([b,g,r]).transpose()
        return opencv_image
    
    def crop_center(img,cropx,cropy):
        h, w = img.shape[:2]
        startx = w//2-(cropx//2)
        starty = h//2-(cropy//2)
        return img[starty:starty+cropy, startx:startx+cropx]
    
    def resize_down_to_1600_max_dim(image):
        h, w = image.shape[:2]
        if (h < 1600 and w < 1600):
            return image
    
        new_size = (1600 * w // h, 1600) if (h > w) else (1600, 1600 * h // w)
        return cv2.resize(image, new_size, interpolation = cv2.INTER_LINEAR)
    
    def resize_to_256_square(image):
        h, w = image.shape[:2]
        return cv2.resize(image, (256, 256), interpolation = cv2.INTER_LINEAR)
    
    def update_orientation(image):
        exif_orientation_tag = 0x0112
        if hasattr(image, '_getexif'):
            exif = image._getexif()
            if (exif != None and exif_orientation_tag in exif):
                orientation = exif.get(exif_orientation_tag, 1)
                # orientation is 1 based, shift to zero based and flip/transpose based on 0-based values
                orientation -= 1
                if orientation >= 4:
                    image = image.transpose(Image.TRANSPOSE)
                if orientation == 2 or orientation == 3 or orientation == 6 or orientation == 7:
                    image = image.transpose(Image.FLIP_TOP_BOTTOM)
                if orientation == 1 or orientation == 2 or orientation == 5 or orientation == 6:
                    image = image.transpose(Image.FLIP_LEFT_RIGHT)
        return image
    
    
    def analyse(hubManager):
    
        messages_sent = 0;
    
        while True:
            #def send_message():
            print ("Load the model into the project")
            # These names are part of the model and cannot be changed.
            output_layer = 'loss:0'
            input_node = 'Placeholder:0'
    
            graph_def = tf.GraphDef()
            labels = []
    
            labels_filename = "labels.txt"
            filename = "model.pb"
    
            # Import the TF graph
            with tf.gfile.FastGFile(filename, 'rb') as f:
                graph_def.ParseFromString(f.read())
                tf.import_graph_def(graph_def, name='')
    
            # Create a list of labels
            with open(labels_filename, 'rt') as lf:
                for l in lf:
                    labels.append(l.strip())
            print ("Model loaded into the project")
    
            results_dic = dict()
    
            # create the JSON to be sent as a message
            json_message = ''
    
            # Iterate through images 
            print ("List of images to analyse:")
            for file in os.listdir('images'):
                print(file)
    
                image = Image.open("images/" + file)
    
                # Update orientation based on EXIF tags, if the file has orientation info.
                image = update_orientation(image)
    
                # Convert to OpenCV format
                image = convert_to_opencv(image)
    
                # If the image has either w or h greater than 1600 we resize it down respecting
                # aspect ratio such that the largest dimension is 1600
                image = resize_down_to_1600_max_dim(image)
    
                # We next get the largest center square
                h, w = image.shape[:2]
                min_dim = min(w,h)
                max_square_image = crop_center(image, min_dim, min_dim)
    
                # Resize that square down to 256x256
                augmented_image = resize_to_256_square(max_square_image)
    
                # The compact models have a network size of 227x227, the model requires this size.
                network_input_size = 227
    
                # Crop the center for the specified network_input_Size
                augmented_image = crop_center(augmented_image, network_input_size, network_input_size)
    
                try:
                    with tf.Session() as sess:     
                        prob_tensor = sess.graph.get_tensor_by_name(output_layer)
                        predictions, = sess.run(prob_tensor, {input_node: [augmented_image] })
                except Exception as identifier:
                    print ("Identifier error: ", identifier)
    
                print ("Print the highest probability label")
                highest_probability_index = np.argmax(predictions)
                print('FINAL RESULT! Classified as: ' + labels[highest_probability_index])
    
                l = labels[highest_probability_index]
    
                results_dic[file] = l
    
                # Or you can print out all of the results mapping labels to probabilities.
                label_index = 0
                for p in predictions:
                    truncated_probablity = np.float64(round(p,8))
                    print (labels[label_index], truncated_probablity)
                    label_index += 1
    
            print("Results dictionary")
            print(results_dic)
    
            json_message = json.dumps(results_dic)
            print("Json result")
            print(json_message)
    
            # Initialize a new message
            message = IoTHubMessage(bytearray(json_message, 'utf8'))
    
            hubManager.send_event_to_output("output1", message, 0)
    
            messages_sent += 1
            print("Message sent! - Total: " + str(messages_sent))      
            print('----------------------------')
    
            # This is the wait time before repeating the analysis
            # Currently set to 10 seconds
            time.sleep(10)
    
    
    class HubManager(object):
    
        def __init__(
                self,
                protocol=IoTHubTransportProvider.MQTT):
            self.client_protocol = protocol
            self.client = IoTHubModuleClient()
            self.client.create_from_environment(protocol)
    
            # set the time until a message times out
            self.client.set_option("messageTimeout", MESSAGE_TIMEOUT)
    
        # Forwards the message received onto the next stage in the process.
        def forward_event_to_output(self, outputQueueName, event, send_context):
            self.client.send_event_async(
                outputQueueName, event, send_confirmation_callback, send_context)
    
        def send_event_to_output(self, outputQueueName, event, send_context):
            self.client.send_event_async(outputQueueName, event, send_confirmation_callback, send_context)
    
    def main(protocol):
        try:
            hub_manager = HubManager(protocol)
            analyse(hub_manager)
            while True:
                time.sleep(1)
    
        except IoTHubError as iothub_error:
            print ( "Unexpected error %s from IoTHub" % iothub_error )
            return
        except KeyboardInterrupt:
            print ( "IoTHubModuleClient sample stopped" )
    
    if __name__ == '__main__':
        main(PROTOCOL)
    
  3. 打开名为 requirements.txt 的文件,并将其内容替换为以下内容:Open the file called requirements.txt, and substitute its content with the following:

    azure-iothub-device-client==1.4.0.0b3
    opencv-python==3.3.1.11
    tensorflow==1.8.0
    pillow==5.1.0
    
  4. 打开名为deployment.template.js的文件,并 根据 以下准则来替换其内容:Open the file called deployment.template.json, and substitute its content following the below guideline:

    1. 因为你将拥有自己的唯一的 JSON 结构,所以需要 (手动编辑该结构,而不是复制) 的示例。Because you will have your own, unique, JSON structure, you will need to edit it by hand (rather than copying an example). 为此,请使用以下图像作为指导。To make this easy, use the below image as a guide.

    2. 外观与你的区域不同,但你 不应更改为黄色Areas which will look different to yours, but which you should NOT change are highlighted yellow.

    3. 您需要删除的部分将突出显示为红色。Sections which you need to delete, are a highlighted red.

    4. 请注意删除正确的方括号,同时删除逗号。Be careful to delete the correct brackets, and also remove the commas.

      创建容器

    5. 但是,已完成的 JSON 应该如下图所示 (但唯一的区别在于: 用户名/密码/模块名称/模块引用) :The completed JSON should look like the following image (though, with your unique differences: username/password/module name/module references):

      创建容器

  5. 打开名为 Dockerfile 的文件,并将其内容替换为以下内容:Open the file called Dockerfile.amd64, and substitute its content with the following:

    FROM ubuntu:xenial
    
    WORKDIR /app
    
    RUN apt-get update && \
        apt-get install -y --no-install-recommends libcurl4-openssl-dev python-pip libboost-python-dev && \
        rm -rf /var/lib/apt/lists/* 
    RUN pip install --upgrade pip
    RUN pip install setuptools
    
    COPY requirements.txt ./
    RUN pip install -r requirements.txt
    
    RUN pip install pillow
    RUN pip install numpy
    
    RUN apt-get update && apt-get install -y \ 
        pkg-config \
        python-dev \ 
        python-opencv \ 
        libopencv-dev \ 
        libav-tools  \ 
        libjpeg-dev \ 
        libpng-dev \ 
        libtiff-dev \ 
        libjasper-dev \ 
        python-numpy \ 
        python-pycurl \ 
        python-opencv
    
    
    RUN pip install opencv-python
    RUN pip install tensorflow
    RUN pip install --upgrade tensorflow
    
    COPY . .
    
    RUN useradd -ms /bin/bash moduleuser
    USER moduleuser
    
    CMD [ "python", "-u", "./main.py" ]
    
    
  6. 右键单击 " 模块 " 下的文件夹 (它将具有之前提供的名称;在下面的示例中,它称为 " pythonmodule) ",然后单击 " 新建文件夹"。Right-click on the folder beneath modules (it will have the name you provided previously; in the example further down, it is called pythonmodule), and click on New Folder. 将文件夹命名为 imagesName the folder images.

  7. 在该文件夹中,添加包含鼠标或键盘的一些图像。Inside the folder, add some images containing mouse or keyboard. 这些将是 Tensorflow 模型将分析的映像。Those will be the images that will be analyzed by the Tensorflow model.

    警告

    如果你使用自己的模型,则需要更改此以反映你自己的模型数据。If you are using your own model, you will need to change this to reflect your own models data.

  8. 现在,你将需要从你之前从其下载的模型文件夹中检索 labels.txt 和 (文件 ,并在第1章中从自己的 自定义影像服务) 中创建这些文件。You will now need to retrieve the labels.txt and model.pb files from the model folder, which you previous downloaded (or created from your own Custom Vision Service), in Chapter 1. 获得这些文件后,请将它们放在解决方案中,并将它们放在其他文件中。Once you have the files, place them within your solution, alongside the other files. 最终结果应该如下图所示:The final result should look like the image below:

    创建容器

第9章-将解决方案打包为容器Chapter 9 - Package the solution as a container

  1. 现在,你可以将文件 "打包" 为容器并将其推送到 Azure 容器注册表You are now ready to "package" your files as a container and push it to your Azure Container Registry. 在 VS Code 中,打开 "集成终端" ("视图 > " "集成终端" 或 " Ctrl + `) ",并使用以下行登录到 Docker (将命令的值替换为 Azure 容器注册表的凭据 (ACR)) :Within VS Code, open the Integrated Terminal (View > Integrated Terminal or Ctrl+`), and use the following line to login to Docker (substitute the values of the command with the credentials of your Azure Container Registry (ACR)):

        docker login -u <ACR username> -p <ACR password> <ACR login server>
    
  2. 右键单击 deployment.template.js 的文件,然后单击 " 生成 IoT Edge 解决方案"。Right-click on the file deployment.template.json, and click Build IoT Edge Solution. 此生成过程需要一段时间, (具体取决于你的设备) ,因此请准备好等待。This build process takes quite some time (depending on your device), so be prepared to wait. 生成过程完成后,会在名为 config 的新文件夹中创建文件 deployment.jsAfter the build process finishes, a deployment.json file will have been created inside a new folder called config.

    创建部署

  3. 再次打开 命令面板 ,然后搜索 " Azure:登录"。Open the Command Palette again, and search for Azure: Sign In. 按照使用 Azure 帐户凭据的提示进行操作;VS Code 将向你提供一个选项,用于 复制和打开,这将会复制你即将需要的设备代码,并打开默认 web 浏览器。Follow the prompts using your Azure Account credentials; VS Code will provide you with an option to Copy and Open, which will copy the device code you will soon need, and open your default web browser. 当系统询问时,粘贴设备代码以对计算机进行身份验证。When asked, paste the device code, to authenticate your machine.

    复制并打开

  4. 登录后,将在 " 浏览 " 面板的底部看到一个名为 " Azure IoT 中心设备" 的新部分。Once signed in you will notice, on the bottom side of the Explore panel, a new section called Azure IoT Hub Devices. 单击此部分以将其展开。Click this section to expand it.

    边缘设备

  5. 如果你的设备不在此处,你需要右键单击 " Azure IoT 中心设备",然后单击 " 设置 IoT 中心连接字符串"。If your device is not here, you will need to right-click Azure IoT Hub Devices, and then click Set IoT Hub Connection String. 然后,你将看到 命令面板 (在 VS Code) 的顶部,将提示你输入 连接字符串You will then see that the Command Palette (at the top of VS Code), will prompt you to input your Connection String. 这是你在 第3章末尾记下的 连接字符串This is the Connection String you noted down at the end of Chapter 3. 在中复制字符串后,按 enter 键。Press the Enter key, once you have copied the string in.

  6. 设备应加载并显示。Your device should load, and appear. 右键单击设备名称,然后单击 " 创建单个设备的部署"。Right-click on the device name, and then click, Create Deployment for Single Device.

    创建部署

  7. 你将看到一个 文件资源管理器 提示,你可以在其中导航到 config 文件夹,然后选择 " deployment.js 文件。You will get a File Explorer prompt, where you can navigate to the config folder, and then select the deployment.json file. 选择该文件后,单击 " 选择边缘部署清单 " 按钮。With that file selected, click the Select Edge Deployment Manifest button.

    创建部署

  8. 此时,你已为 IoT 中心服务 提供了一个清单,用于从 Azure 容器注册表 将容器(作为模块)部署到你的设备,并有效地将其部署到设备。At this point you have provided your IoT Hub Service with the manifest for it to deploy your container, as a module, from your Azure Container Registry, effectively deploying it to your device.

  9. 若要查看从设备发送到 IoT 中心的消息,请再次右键单击 " Azure IoT 中心设备 " 部分中的设备名称,然后在 " 资源管理器 " 面板中单击 " 开始监视 D2C 消息"。To view the messages sent from your device to the IoT Hub, right-click again on your device name in the Azure IoT Hub Devices section, in the Explorer panel, and click on Start Monitoring D2C Message. 设备发送的消息应显示在 VS 终端中。The messages sent from your device should appear in the VS Terminal. 请耐心等待,因为这可能需要一些时间。Be patient, as this may take some time. 请参阅下一章进行调试,并检查部署是否成功。See the next Chapter for debugging, and checking if deployment was successful.

此模块现在将在 images 文件夹中的图像之间进行循环访问,并在每次迭代时进行分析。This module will now iterate between the images in the images folder and analyze them, with each iteration. 这显然只是演示如何获取基本机器学习模型,以便在 IoT Edge 设备环境中工作。This is obviously just a demonstration of how to get the basic machine learning model to work in an IoT Edge device environment.

若要扩展此示例的功能,可以通过多种方式继续操作。To expand the functionality of this example, you could proceed in several ways. 其中一种方法可能是在容器中包含某些代码,这些代码从连接到设备的网络摄像机捕获照片,并将图像保存到 images 文件夹中。One way could be including some code in the container, that captures photos from a webcam that is connected to the device, and saves the images in the images folder.

另一种方法是将映像从 IoT 设备复制到容器中。Another way could be copying the images from the IoT device into the container. 实现此目的的一种可行方法是在 IoT 设备终端中运行以下命令,如果你希望自动执行此) 过程,则可能是小应用程序可以执行该作业 (。A practical way to do that is to run the following command in the IoT device Terminal (perhaps a small app could do the job, if you wished to automate the process). 可以通过从存储文件的文件夹位置手动运行此命令来对其进行测试:You can test this command by running it manually from the folder location where your files are stored:

    sudo docker cp <filename> <modulename>:/app/images/<a name of your choice>

第10章-调试 IoT Edge 运行时Chapter 10 - Debugging the IoT Edge Runtime

下面是命令行和提示的列表,可帮助你从 Ubuntu 设备 监视和调试 IoT Edge 运行时 的消息传递活动。The following are a list of command lines, and tips, to help you monitor and debug the messaging activity of the IoT Edge Runtime, from your Ubuntu device.

  • 通过运行以下命令行检查 IoT Edge 运行时 状态:Check the IoT Edge Runtime status by running the following command line:

        sudo systemctl status iotedge
    

    备注

    请记得按 Ctrl + C 来完成状态的查看。Remember to press Ctrl + C, to finish viewing the status.

  • 列出当前部署的容器。List the containers that are currently deployed. 如果 IoT 中心服务 成功部署了容器,则会通过运行以下命令行来显示它们:If the IoT Hub Service has deployed the containers successfully, they will be displayed by running the following command line:

        sudo iotedge list
    

    Or

        sudo docker ps
    

    备注

    以上是检查模块是否已成功部署的好方法,因为它将出现在列表中;否则,你将 看到 edgeHubedgeAgentThe above is a good way to check whether your module has been deployed successfully, as it will appear in the list; you will otherwise only see the edgeHub and edgeAgent.

  • 若要显示容器的代码日志,请运行以下命令行:To display the code logs of a container, run the following command line:

        journalctl -u iotedge
    

用于管理 IoT Edge 运行时的有用命令:Useful commands to manage the IoT Edge Runtime:

  • 删除主机中的所有容器:To delete all containers in the host:

        sudo docker rm -f $(sudo docker ps -aq)
    
  • 若要停止 IoT Edge 运行时To stop the IoT Edge Runtime:

        sudo systemctl stop iotedge
    

第11章-创建表服务Chapter 11 - Create Table Service

导航回到 Azure 门户,在该门户中创建存储资源。Navigate back to your Azure Portal, where you will create an Azure Tables Service, by creating a Storage resource.

  1. 如果尚未登录,请登录到 Azure 门户If not already signed in, log into the Azure Portal.

  2. 登录后,单击左上角的 " 创建资源",搜索 " 存储帐户",然后按 enter 键开始搜索。Once logged in, click on Create a resource, in the top left corner, and search for Storage account, and press the Enter key, to start the search.

  3. 出现后,单击列表中的 " 存储帐户-blob、文件、表、队列 "。Once it has appeared, click Storage account - blob, file, table, queue from the list.

    搜索存储帐户

  4. 新页将提供 存储帐户 服务的说明。The new page will provide a description of the Storage account Service. 在此提示符的左下方,单击 " 创建 " 按钮以创建此服务的实例。At the bottom left of this prompt, click the Create button, to create an instance of this Service.

    创建存储实例

  5. 单击 " 创建" 后,将显示一个面板:Once you have clicked on Create, a panel will appear:

    1. 为此服务实例插入所需的 名称 , (必须全部为小写) 。Insert your desired Name for this Service instance (must be all lowercase).

    2. 对于 部署模型,单击 " 资源管理器"。For Deployment model, click Resource manager.

    3. 对于 " 帐户类型",请使用下拉菜单,单击 " 存储 (常规用途 v1)For Account kind, using the dropdown menu, click Storage (general purpose v1).

    4. 单击适当的 位置Click an appropriate Location.

    5. 对于 " 复制 " 下拉菜单,单击 " 读取-访问-异地冗余存储 (GRS)"。For the Replication dropdown menu, click Read-access-geo-redundant storage (RA-GRS).

    6. 对于 " 性能",请单击 " 标准"。For Performance, click Standard.

    7. 在 " 需要安全传输 " 部分中,单击 " 禁用"。Within the Secure transfer required section, click Disabled.

    8. 从 " 订阅 " 下拉菜单中,单击相应的订阅。From the Subscription dropdown menu, click an appropriate subscription.

    9. 选择一个 资源组 ,或创建一个新的资源组。Choose a Resource Group or create a new one. 资源组提供一种方式来监视、控制访问、预配和管理 Azure 资产集合的计费。A resource group provides a way to monitor, control access, provision, and manage, billing for a collection of Azure assets. 建议保留与单个项目关联的所有 Azure 服务 (例如,这些课程) 常用资源组) 下。It is recommended to keep all the Azure Services associated with a single project (e.g. such as these courses) under a common resource group).

      如果希望了解有关 Azure 资源组的详细信息,请参阅此 链接,了解如何管理资源组If you wish to read more about Azure Resource Groups, please follow this link on how to manage a Resource Group.

    10. 如果这是一个选项,请将 虚拟网络 保留为 禁用状态Leave Virtual networks as Disabled, if this is an option for you.

    11. 单击“创建”。Click Create.

      填写存储详细信息

  6. 单击 " 创建" 后,需要等待创建服务,这可能需要一分钟时间。Once you have clicked on Create, you will have to wait for the Service to be created, this might take a minute.

  7. 创建服务实例后,门户中将显示一个通知。A notification will appear in the Portal once the Service instance is created. 单击通知以浏览新服务实例。Click on the notifications to explore your new Service instance.

    新存储通知

  8. 单击通知中的 " 转到资源 " 按钮,会转到 "新建存储服务实例概述" 页。Click the Go to resource button in the notification, and you will be taken to your new Storage Service instance overview page.

    中转到资源

  9. 在 "概述" 页中,单击右侧的 " "。From the overview page, to the right-hand side, click Tables.

    表

  10. 右侧面板将更改为显示 表服务 信息,你需要添加一个新表。The panel on the right will change to show the Table Service information, wherein you need to add a new table. 单击左上角的 " + 表 " 按钮即可执行此操作。Do this by clicking the + Table button to the top-left corner.

    打开表

  11. 将显示一个新页,需要在其中输入 表名称A new page will be shown, wherein you need to enter a Table name. 这是你将用于在后面的章节中引用应用程序中的数据 (创建 Function App 和 Power BI) 的名称。This is the name you will use to refer to the data in your application in later Chapters (creating Function App, and Power BI). IoTMessages 作为名称插入 (你可以自行选择,只需记住它,稍后在本文档中使用) 然后单击 "确定"Insert IoTMessages as the name (you can choose your own, just remember it when used later in this document) and click OK.

  12. 创建新表后,可在 " 表服务 " 页的底部) (查看它。Once the new table has been created, you will be able to see it within the Table Service page (at the bottom).

    已创建新表

  13. 现在,单击 " 访问密钥 ",然后使用记事本) 复制 存储帐户名称密钥 (,你将在本课程中创建 Azure Function App 时使用这些值。Now click on Access keys and take a copy of the Storage account name and Key (using your Notepad), you will use these values later in this course, when creating the Azure Function App.

    已创建新表

  14. 再次使用左侧的面板,滚动到 " 表服务 " 部分,单击 " " " (" 或 " 浏览" "表 ) () "。Using the panel on the left again, scroll to the Table Service section, and click Tables (or Browse Tables, in newer Portals) and take a copy of the Table URL (using your Notepad). 在本课程中,将表链接到 Power BI 应用程序时,将使用此值。You will use this value later in this course, when linking your table to your Power BI application.

    已创建新表

第12章-完成 Azure 表Chapter 12 - Completing the Azure Table

由于已设置了 表服务 存储帐户,因此可以向其添加数据,这将用于存储和检索信息。Now that your Table Service storage account has been setup, it is time to add data to it, which will be used to store and retrieve information. 可以通过 Visual Studio 来编辑表。The editing of your Tables can be done through Visual Studio.

  1. 打开 " Visual Studio ( Visual Studio Code) "。Open Visual Studio (not Visual Studio Code).

  2. 从菜单中,单击 "查看 > Cloud Explorer"。From the menu, click View > Cloud Explorer.

    打开 cloud explorer

  3. Cloud Explorer 将作为停靠项打开 (患者,因为加载可能需要一些时间) 。The Cloud Explorer will open as a docked item (be patient, as loading may take time).

    警告

    如果用于创建 存储帐户 的订阅不可见,请确保:If the subscription you used to create your Storage Accounts is not visible, ensure that you have:

    • 已登录到与 Azure 门户一起使用的帐户。Logged in to the same account as the one you used for the Azure Portal.

    • 从 "帐户管理" 页中选择了你的订阅 (你可能需要从帐户设置) 应用筛选器:Selected your subscription from the Account Management page (you may need to apply a filter from your account settings):

      查找订阅

  4. 将显示你的 Azure 云服务。Your Azure cloud Services will be shown. 查找 存储帐户 ,并单击其左侧的箭头以展开你的帐户。Find Storage Accounts and click the arrow to the left of that to expand your accounts.

    打开存储帐户

  5. 展开后,新创建的 存储帐户 应该可用。Once expanded, your newly created Storage account should be available. 单击存储左侧的箭头,然后在展开后,查找 " " 并单击该按钮旁边的箭头,以显示在上一章中创建的 Click the arrow to the left of your storage, and then once that is expanded, find Tables and click the arrow next to that, to reveal the Table you created in the last Chapter. 双击 Double-click your Table.

  6. 您的表将在您的 Visual Studio 窗口的中心打开。Your table will be opened in the center of your Visual Studio window. 单击带有 + (加) 的表图标。Click the table icon with the + (plus) on it.

    添加新表

  7. 将显示一个窗口,提示你 添加实体A window will appear prompting for you to Add Entity. 您将只创建一个实体,但它将具有三个属性。You will create only one entity, though it will have three properties. 你会注意到已提供了 PartitionKeyRowKey ,因为表使用这些方法来查找数据。You will notice that PartitionKey and RowKey are already provided, as these are used by the table to find your data.

    分区和行键

  8. 请更新以下值:Update the following values:

    • 名称: PartitionKey,值: PK_IoTMessagesName: PartitionKey, Value: PK_IoTMessages

    • 名称: RowKey,值: RK_1_IoTMessagesName: RowKey, Value: RK_1_IoTMessages

  9. 然后,单击 "添加实体" 窗口左下角的 "添加属性" () 并添加以下属性:Then, click Add property (to the lower left of the Add Entity window) and add the following property:

    • MessageContent ,将值 保留为空。MessageContent, as a string, leave the Value empty.
  10. 表应与下图中的表匹配:Your table should match the one in the image below:

    添加正确的值

    备注

    在行键中,实体的编号为1的原因是,您可能需要添加更多的消息,而您希望在本课程中进行进一步试验。The reason why the entity has the number 1 in the row key, is because you might want to add more messages, should you desire to experiment further with this course.

  11. 完成后,单击 "确定"Click OK when you are finished. 现在可以使用表了。Your table is now ready to be used.

第13章-创建 Azure Function AppChapter 13 - Create an Azure Function App

现在可以创建一个 Azure Function AppIoT 中心服务 将调用该将 IoT Edge 设备消息存储在之前章节中创建的 服务中。It is now time to create an Azure Function App, which will be called by the IoT Hub Service to store the IoT Edge device messages in the Table Service, which you created in the previous Chapter.

首先,需要创建一个文件,该文件允许 Azure 函数加载所需的库。First, you need to create a file that will allow your Azure Function to load the libraries you need.

  1. 打开 记事本 (按 Windows 键,然后键入 Notepad) 。Open Notepad (press the Windows Key, and type notepad).

    打开记事本

  2. 打开记事本后,将下面的 JSON 结构插入其中。With Notepad open, insert the JSON structure below into it. 完成此操作后,将其保存在桌面上,就 project.jsOnce you have done that, save it on your desktop as project.json. 此文件定义函数将使用的库。This file defines the libraries your function will use. 如果使用了 NuGet,则会很熟悉。If you have used NuGet, it will look familiar.

    警告

    命名正确,这一点很重要。确保它没有 .txt 文件扩展名。It is important that the naming is correct; ensure it does NOT have a .txt file extension. 请参阅下面的参考:See below for reference:

    JSON 保存

    {
    "frameworks": {
        "net46":{
        "dependencies": {
            "WindowsAzure.Storage": "9.2.0"
        }
        }
    }
    }
    
  3. 登录到 Azure 门户Log in to the Azure Portal.

  4. 登录后,单击左上角的 " 创建资源 ",搜索 Function App,然后按 enter 键进行搜索。Once you are logged in, click on Create a resource in the top left corner, and search for Function App, and press the Enter key, to search. 在结果中单击 " Function App " 以打开新面板。Click Function App from the results, to open a new panel.

    搜索函数应用

  5. 新面板将提供 Function App 服务的说明。The new panel will provide a description of the Function App Service. 在此面板的左下方,单击 " 创建 " 按钮以创建与此服务的关联。At the bottom left of this panel, click the Create button, to create an association with this Service.

    function app 实例

  6. 单击 " 创建" 后,请填写以下内容:Once you have clicked on Create, fill in the following:

    1. 对于 " 应用名称",请为此服务实例插入所需的名称。For App name, insert your desired name for this Service instance.

    2. 选择一个“订阅” 。Select a Subscription.

    3. 选择适合你的定价层,如果这是第一次创建 Function App 服务,则应提供免费层。Select the pricing tier appropriate for you, if this is the first time creating a Function App Service, a free tier should be available to you.

    4. 选择一个 资源组 ,或创建一个新的资源组。Choose a Resource Group or create a new one. 资源组提供一种方式来监视、控制访问、预配和管理 Azure 资产集合的计费。A resource group provides a way to monitor, control access, provision, and manage, billing for a collection of Azure assets. 建议保留与单个项目关联的所有 Azure 服务 (例如,这些课程) 常用资源组) 下。It is recommended to keep all the Azure Services associated with a single project (e.g. such as these courses) under a common resource group).

      如果希望了解有关 Azure 资源组的详细信息,请参阅此 链接,了解如何管理资源组If you wish to read more about Azure Resource Groups, please follow this link on how to manage a Resource Group.

    5. 对于 操作系统,请单击 "Windows",因为这是预期的平台。For OS, click Windows, as that is the intended platform.

    6. 选择一种 托管计划 (本教程将使用 消耗计划Select a Hosting Plan (this tutorial is using a Consumption Plan.

    7. 选择一个 位置 (选择与在上一步骤中生成的存储相同的位置) Select a Location (choose the same location as the storage you have built in the previous step)

    8. 对于 " 存储 " 部分, 你必须选择在上一步中创建的存储服务For the Storage section, you must select the Storage Service you created in the previous step.

    9. 在此应用中不需要 Application Insights ,因此可随意将其 关闭You will not need Application Insights in this app, so feel free to leave it Off.

    10. 单击“创建”。Click Create.

      创建新实例

  7. 单击 " 创建" 后,需要等待创建服务,这可能需要一分钟时间。Once you have clicked on Create, you will have to wait for the Service to be created, this might take a minute.

  8. 创建服务实例后,门户中将显示一个通知。A notification will appear in the Portal once the Service instance is created.

    新建通知

  9. 在成功完成部署后 () 单击通知。Click on the notification, once deployment is successful (has finished).

  10. 单击通知中的 " 中转到资源 " 按钮以浏览新服务实例。Click the Go to resource button in the notification to explore your new Service instance.

    中转到资源

  11. 在新面板的左侧,单击 " + 函数" 旁边的 (加) 图标,以创建新函数。In the left side of the new panel, click the + (plus) icon next to Functions, to create a new function.

    添加新函数

  12. 在中央面板中,将显示 " 函数 创建" 窗口。Within the central panel, the Function creation window will appear. 进一步向下滚动,然后单击 " 自定义函数"。Scroll down further, and click on Custom function.

    自定义函数

  13. 在下一页上向下滚动,直到找到 IoT 中心 (事件中心 "),然后单击它。Scroll down the next page, until you find IoT Hub (Event Hub), then click on it.

    自定义函数

  14. IoT 中心 (事件中心) "边栏选项卡中,将" 语言 "设置为" c # ",然后单击" 新建"。In the IoT Hub (Event Hub) blade, set the Language to C# and then click on new.

    自定义函数

  15. 在出现的窗口中,确保已选中 " Iot 中心",并且 " iot 中心" 字段的名称对应于你之前 在第3章) 的步骤8中 (的 iot 中心服务 的名称。In the window that will appear, make sure that IoT Hub is selected and the name of the IoT Hub field corresponds with the name of your IoT Hub Service that you have created previously (in step 8, of Chapter 3). 然后单击 " 选择 " 按钮。Then click the Select button.

    自定义函数

  16. 返回到 IoT 中心 (事件中心) "边栏选项卡上,单击" 创建"。Back on the IoT Hub (Event Hub) blade, click on Create.

    自定义函数

  17. 你将被重定向到函数编辑器。You will be redirected to the function editor.

    自定义函数

  18. 删除其中的所有代码,并将其替换为以下代码:Delete all the code in it and replace it with the following:

    #r "Microsoft.WindowsAzure.Storage"
    #r "NewtonSoft.Json"
    
    using System;
    using Microsoft.WindowsAzure.Storage;
    using Microsoft.WindowsAzure.Storage.Table;
    using Newtonsoft.Json;
    using System.Threading.Tasks;
    
    public static async Task Run(string myIoTHubMessage, TraceWriter log)
    {
        log.Info($"C# IoT Hub trigger function processed a message: {myIoTHubMessage}");
    
        //RowKey of the table object to be changed
        string tableName = "IoTMessages";
        string tableURL = "https://iothubmrstorage.table.core.windows.net/IoTMessages";
    
        // If you did not name your Storage Service as suggested in the course, change the name here with the one you chose.
        string storageAccountName = "iotedgestor"; 
    
        string storageAccountKey = "<Insert your Storage Key here>";   
    
        string partitionKey = "PK_IoTMessages";
        string rowKey = "RK_1_IoTMessages";
    
        Microsoft.WindowsAzure.Storage.Auth.StorageCredentials storageCredentials =
            new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(storageAccountName, storageAccountKey);
    
        CloudStorageAccount storageAccount = new CloudStorageAccount(storageCredentials, true);
    
        // Create the table client.
        CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
    
        // Get a reference to a table named "IoTMessages"
        CloudTable messageTable = tableClient.GetTableReference(tableName);
    
        //Retrieve the table object by its RowKey
        TableOperation operation = TableOperation.Retrieve<MessageEntity>(partitionKey, rowKey);
        TableResult result = await messageTable.ExecuteAsync(operation);
    
        //Create a MessageEntity so to set its parameters
        MessageEntity messageEntity = (MessageEntity)result.Result;
    
        messageEntity.MessageContent = myIoTHubMessage;
        messageEntity.PartitionKey = partitionKey;
        messageEntity.RowKey = rowKey;
    
        //Replace the table appropriate table Entity with the value of the MessageEntity Ccass structure.
        operation = TableOperation.Replace(messageEntity);
    
        // Execute the insert operation.
        await messageTable.ExecuteAsync(operation);
    }
    
    // This MessageEntity structure which will represent a Table Entity
    public class MessageEntity : TableEntity
    {
        public string Type { get; set; }
        public string MessageContent { get; set; }   
    }
    
  19. 更改以下变量,使其对应于 (存储 值的相应值, 分别为第11章) 的第11章和第13章 ,你将在 存储帐户 中找到:Change the following variables, so that they correspond to the appropriate values (Table and Storage values, from step 11 and 13, respectively, of Chapter 11), that you will find in your Storage Account:

    • tableName,其中包含你的 存储帐户 中的 的名称。tableName, with the name of your Table located in your Storage Account.
    • tableURL,其中包含你的 存储帐户 中的 的 URL。tableURL, with the URL of your Table located in your Storage Account.
    • storageAccountName,其中包含与你的 存储帐户 名称的名称相对应的值的名称。storageAccountName, with the name of the value corresponding with the name of your Storage Account name.
    • storageAccountKey,其中包含你之前在创建的存储服务中获得的密钥。storageAccountKey, with the Key you have obtained in the Storage Service you have created previously.

    自定义函数

  20. 在代码准备就绪后,单击 " 保存"。With the code in place, click Save.

  21. 接下来,单击 < 页面右侧) 图标 (箭头。Next, click the < (arrow) icon, on the right-hand side of the page.

    自定义函数

  22. 面板会从右侧滑入。A panel will slide in from the right. 在该面板中,单击 " 上载",将显示 文件浏览器In that panel, click Upload, and a File Browser will appear.

  23. 导航到,然后单击 " project.js 文件,该文件是您之前在 记事本 中创建的,然后单击" 打开 "按钮。Navigate to, and click, the project.json file, which you created in Notepad previously, and then click the Open button. 此文件定义函数将使用的库。This file defines the libraries that your function will use.

    自定义函数

  24. 文件上传后,它将显示在右侧的面板中。When the file has uploaded, it will appear in the panel on the right. 单击它会在 函数 编辑器中打开它。Clicking it will open it within the Function editor. 它必须与下一个图像 完全 相同。It must look exactly the same as the next image.

    自定义函数

  25. 此时,最好测试函数将消息存储在 中的功能。At this point it would be good to test the capability of your Function to store the message on your Table. 在窗口的右上角,单击 " 测试"。On the top right side of the window, click on Test.

    自定义函数

  26. 请求正文 中插入一条消息(如上图所示),然后单击 " 运行"。Insert a message on the Request body, as shown in the image above, and click on Run.

  27. 该函数将运行,并显示结果状态 (你会注意 *到 "已*接受绿色状态 202",这意味着它是成功的调用) :The function will run, displaying the result status (you will notice the green Status 202 Accepted, above the Output window, which means it was a successful call):

    输出结果

第14章-查看活动消息Chapter 14 - View active messages

如果你现在打开 Visual Studio ( Visual Studio Code) ,则可以可视化测试消息结果,因为它将存储在 MessageContent 字符串区域中。If you now open Visual Studio (not Visual Studio Code), you can visualize your test message result, as it will be stored in the MessageContent string area.

自定义函数

在表服务和 Function App 就绪后,Ubuntu 设备消息将显示在 IoTMessages 表中。With the Table Service and Function App in place, your Ubuntu device messages will appear in your IoTMessages Table. 如果尚未运行,则重新启动设备,你将能够通过使用 Visual Studio Cloud Explorer 在表中看到来自你的设备和模块的结果消息。If not already running, start your device again, and you will be able to see the result messages from your device, and module, within your Table, through using Visual Studio Cloud Explorer.

可视化数据

第15章-Power BI 安装Chapter 15 - Power BI Setup

若要将数据从 IOT 设备中可视化,你需要设置 Power BI (桌面版本) ,以便从你刚创建的 服务中收集数据。To visualize the data from your IOT device you will setup Power BI (desktop version), to collect the data from the Table Service, which you just created. Power BI 的 HoloLens 版本随后将使用该数据来可视化结果。The HoloLens version of Power BI will then use that data to visualize the result.

  1. 在 Windows 10 上打开 Microsoft Store,并搜索 Power BI DesktopOpen the Microsoft Store on Windows 10 and search for Power BI Desktop.

    Power BI

  2. 下载应用程序。Download the application. 完成下载后,请将其打开。Once it has finished downloading, open it.

  3. Microsoft 365 帐户 登录 Power BILog into Power BI with your Microsoft 365 account. 你可能会被重定向到浏览器进行注册。You may be redirected to a browser, to sign up. 注册后,返回到 Power BI 应用,然后再次登录。Once you are signed up, go back to the Power BI app, and sign in again.

  4. 单击 " 获取数据 ",然后单击 " 更多 ..."。Click on Get Data and then click on More....

    Power BI

  5. 单击 " azure"、" azure 表存储",然后单击 " 连接"。Click Azure, Azure Table Storage, then click on Connect.

    Power BI

  6. 创建表服务时,系统将提示您插入先前收集的 表 URL (在第11章) 的第13步中You will be prompted to insert the Table URL that you collected earlier (in step 13 of Chapter 11), while creating your Table Service. 插入 URL 后,在本课程) ,删除引用表 "子文件夹" (的部分路径。After inserting the URL, delete the portion of the path referring to the Table "sub-folder" (which was IoTMessages, in this course). 最终结果应如下图所示。The final result should be as displayed in the image below. 然后单击 "确定"Then click on OK.

    Power BI

  7. 创建表存储时,系统将提示你 在前面的第) 11 章的步骤11中插入 (记下的 存储密钥You will be prompted to insert the Storage Key that you noted (in step 11 of Chapter 11) earlier while creating your Table Storage. 然后单击 " 连接"。Then click on Connect.

    Power BI

  8. 将显示 "导航器" 面板 ,勾选表旁边的框,然后单击 " 加载"。A Navigator Panel will be displayed, tick the box next to your Table and click on Load.

    Power BI

  9. 你的表现在已在 Power BI 上加载,但它需要一个查询以显示其中的值。Your table has now been loaded on Power BI, but it requires a query to display the values in it. 为此,请右键单击位于屏幕右侧的 " 字段" 面板 中的表名称。To do so, right-click on the table name located in the FIELDS panel at the right side of the screen. 然后单击 " 编辑查询"。Then click on Edit Query.

    Power BI

  10. Power Query 编辑器 将作为新窗口打开,并显示您的表。A Power Query Editor will open up as a new window, displaying your table. 单击表的 "内容" 列中的字词 记录,以可视化存储的内容。Click on the word Record within the Content column of the table, to visualize your stored content.

    Power BI

  11. 单击窗口左上角的 " 到表"。Click on Into Table, at the top-left of the window.

    Power BI

  12. 单击 " 关闭" & 应用Click on Close & Apply.

    Power BI

  13. 完成加载查询后,在屏幕右侧的 " 字段" 面板 中,勾选与参数 名称 相对应的框,以可视化 MessageContent 列内容。Once it has finished loading the query, within the FIELDS panel, on the right side of the screen, tick the boxes corresponding to the parameters Name and Value, to visualize the MessageContent column content.

    Power BI

  14. 单击窗口左上角的 蓝色磁盘图标 ,将工作保存到所选的文件夹中。Click on the blue disk icon at the top left of the window to save your work in a folder of your choice.

    Power BI

  15. 你现在可以单击 "发布" 按钮将表上传到工作区。You can now click on the Publish button to upload your table to your Workspace. 出现提示时,单击 "我的工作区 " 并单击 " 选择"。When prompted, click My workspace and click Select. 等待它显示成功提交的提交结果。Wait for it to display the successful result of the submission.

    Power BI

    Power BI

警告

下面是特定于 HoloLens 的章节。The following Chapter is HoloLens specific. Power BI 当前不适用于沉浸式应用程序,但你可以通过桌面应用在 Windows Mixed Reality 门户 ((也称为 Cliff 房子) )上运行桌面版本。Power BI is not currently available as an immersive application, however you can run the desktop version in the Windows Mixed Reality Portal (aka Cliff House), through the Desktop app.

第16章-显示 Power BI HoloLens 上的数据Chapter 16 - Display Power BI data on HoloLens

  1. 在 HoloLens 上,通过在应用程序列表中点击其图标来登录到 Microsoft StoreOn your HoloLens, log in to the Microsoft Store, by tapping on its icon in the applications list.

    Power BI HL

  2. 搜索并下载 Power BI 应用程序。Search and then download the Power BI application.

    Power BI HL

  3. 从应用程序列表中启动 Power BIStart Power BI from your applications list.

  4. Power BI 可能会要求你登录到 Microsoft 365 帐户Power BI might ask you to login to your Microsoft 365 account.

  5. 在应用程序中,默认情况下,工作区应显示,如下图所示。Once inside the app, the workspace should display by default as shown in the image below. 如果未执行此操作,只需单击窗口左侧的工作区图标。If that does not happen, simply click on the workspace icon on the left side of the window.

    Power BI HL

已完成 IoT 中心应用程序Your finished your IoT Hub application

恭喜,你已成功创建了一个包含模拟虚拟机边缘设备的 IoT 中心服务。Congratulations, you have successfully created an IoT Hub Service, with a simulated Virtual Machine Edge device. 你的设备可以将机器学习模型的结果传达给 Azure 表服务,该服务由 Azure Function App (读入 Power BI 并在 Microsoft HoloLens 中进行可视化)促进。Your device can communicate the results of a machine learning model to an Azure Table Service, facilitated by an Azure Function App, which is read into Power BI, and visualized within a Microsoft HoloLens.

Power BI

额外练习Bonus exercises

练习1Exercise 1

展开表中存储的消息结构,并将其显示为图形。Expand the messaging structure stored in the table and display it as a graph. 您可能想要收集更多的数据,并将其存储在同一个表中,以便以后显示。You might want to collect more data and store it in the same table, to be later displayed.

练习2Exercise 2

创建要部署在 IoT 板上的其他 "相机捕获" 模块,使其可以通过要分析的相机捕获映像。Create an additional "camera capture" module to be deployed on the IoT board, so that it can capture images through the camera to be analyzed.