天天看點

Azure IoT Edge入門(2)部署一台Edge Device

Azure IoT Edge入門(2)部署一台Edge Device

案例:部署一台Edge Device(Windows 系統)

通常情況下,部署一台Edge裝置有如下四個步驟:

1. 建立Azure IoT Hub;

2.準備Edge Device(windows/linux),1.準備作業系統,2.在IoT Hub裡建立IoT Edge Device;

3.安裝并配置 Azure IoT Edge Runtime(離線或線上安裝);

4. 從Azure Container Registry 下載下傳業務容器,由業務容器開始發送遙測消息給Azure IoT Hub;

今天這一小節,介紹前三個步驟。

關于Azure Container Regisgtry,請參見《Azure Container Registry》

Azure IoT Edge入門(2)部署一台Edge Device

本文主要介紹:

1. IoT Edge Runtime 對作業系統的要求  

2. 準備Edge device(在azure 上購買一台Windows Server 2019)

3.準備Azure IoT Hub并建立IoT Edge Device

4.在Edge Device 上安裝 IoT Edge Runtime

   線上安裝;

   離線安裝;

視訊講解:

您可以觀看B站視訊:https://www.bilibili.com/video/av91049338/

或在本站觀看視訊:

deploy-iot-dege-on-windows.mp4

圖文步驟:

IoT Edge 對作業系統的要求,請參見:https://docs.azure.cn/zh-cn/iot-edge/support

主要分為兩種(文檔裡稱為兩層),簡單了解:

第一層系統是由微軟進行過嚴格的Azure IoT Edge Runtime測試,完全相容。

下表中列出的系統(不管是公開釋出版還是公共預覽版)受 Microsoft 的支援,并在每個新版本中進行了測試。

作業系統 AMD64 ARM32v7 ARM64
Raspbian Stretch
Azure IoT Edge入門(2)部署一台Edge Device
Ubuntu Server 16.04
Azure IoT Edge入門(2)部署一台Edge Device
公共預覽版
Ubuntu Server 18.04
Azure IoT Edge入門(2)部署一台Edge Device
Windows 10 IoT 核心版内部版本 17763
Azure IoT Edge入門(2)部署一台Edge Device
Windows 10 IoT 企業版内部版本 17763
Azure IoT Edge入門(2)部署一台Edge Device
Windows Server 2019 内部版本 17763
Azure IoT Edge入門(2)部署一台Edge Device
Windows Server IoT 2019 内部版本 17763
Azure IoT Edge入門(2)部署一台Edge Device

第二層理論上可相容,或者微軟合作夥伴已經成功運作了的。

CentOS 7.5
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Debian 8
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Debian 9
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Debian 10 1
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Mentor Embedded Linux Flex OS
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Mentor Embedded Linux Omni OS
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
RHEL 7.5
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Ubuntu 16.04
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Ubuntu 18.04
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Wind River 8
Azure IoT Edge入門(2)部署一台Edge Device
Yocto
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device
Raspbian Buster 1
Azure IoT Edge入門(2)部署一台Edge Device
Azure IoT Edge入門(2)部署一台Edge Device

在Azure上準備一台虛拟機作為Edge裝置使用

本案例中使用的是Windows Server 2019 Datacenter (zh-cn),當然可以選擇其他第一層的作業系統。

Azure IoT Edge入門(2)部署一台Edge Device

建立Azure IoT Hub,并建立IoT Edge Device

在IoT Hub-IoT Edge中點選添加IoT Edge裝置

Azure IoT Edge入門(2)部署一台Edge Device

輸入裝置ID,其餘保持預設,點選儲存

Azure IoT Edge入門(2)部署一台Edge Device

在Edge 裝置上安裝IoT Edge Runtime

在windows 中安裝Edge Runtime,請參見:https://docs.azure.cn/zh-cn/iot-edge/how-to-install-iot-edge-windows

注意,本節中,我們選擇安裝和手動預配,手動預配的意思是,在安裝Runtime過程中,需要手動輸入IoT Edge Device的連接配接字元串。

1. 線上安裝Azure IoT Edge Runtime:

登入到Windows Server中,以管理者權限運作如下Power Shell腳本:

. {Invoke-WebRequest -useb https://aka.ms/iotedge-win} | Invoke-Expression; `Deploy-IoTEdge      

畫重點,如果此步驟,報網絡錯誤,可以嘗試打開連接配接 “https://aka.ms/iotedge-win”,如果打不開,可能存在網絡問題,則此時需要使用離線安裝方式。

2.離線安裝Azure IoT Edge Runtime:

在頁面上下載下傳相應的 檔案,https://github.com/Azure/azure-iotedge/releases

Azure IoT Edge入門(2)部署一台Edge Device

對于Windows 系統,需要根據系統是64/32位下載下傳對應的cab檔案和 vc_redist.exe(Visual C++ Redistributable Package)

注意,需要将下載下傳的cab的包重命名為 Microsoft-Azure-IoTEdge.cab

vc_redist.exe 下載下傳位址:vc_redist.exe

Azure IoT Edge入門(2)部署一台Edge Device

然後右鍵拷貝.ps1的路徑,修改如如下的腳本中:

将https://aka.ms/iotedge-win改為https://github.com/Azure/azure-iotedge/releases/download/1.0.9-rc5/IotEdgeSecurityDaemon.ps1,意味着按照更改後的腳本安裝對應的runtime 版本。

. {Invoke-WebRequest -useb https://github.com/Azure/azure-iotedge/releases/download/1.0.9-rc5/IotEdgeSecurityDaemon.ps1} | Invoke-Expression; `Deploy-IoTEdge -OfflineInstallationPath D:\Downloads\iotedgeoffline      

在PowerShell 管理者權限先運作上述腳本,如提示重新開機,則重新開機後需執行如下腳本:

Azure IoT Edge入門(2)部署一台Edge Device
. {Invoke-WebRequest -useb https://aka.ms/iotedge-win} | Invoke-Expression; `Initialize-IoTEdge      

注意:腳本中的 https://aka.ms/iotedge-win,如果安裝的是指定版本,也需要替換為指定版本的ps1檔案路徑。

執行過程中需要按找提示輸入IoT Edge 的連接配接字元串

Azure IoT Edge入門(2)部署一台Edge Device

使用 如下指令檢查 IoT Runtime 運作狀态:

Get-Service iotedge      
Azure IoT Edge入門(2)部署一台Edge Device

使用如下指令檢查目前運作的子產品:

iotedge list      

初次安裝完成,隻有一個edgeagent 子產品,此現象是正常的,其他子產品由edge agent 負責安裝,需要時間。

Azure IoT Edge入門(2)部署一台Edge Device

在Portal上可以檢視IoT Edge 的運作狀态和子產品狀态:

Azure IoT Edge入門(2)部署一台Edge Device

繼續閱讀