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

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

 

1582545637861-9a8932f0-2522-4295-bf26-673f84c14c6e.png

本文主要介紹:

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 的支持,並在每個新版本中進行了測試。

操作系統AMD64ARM32v7ARM64
Raspbian Stretch
1582545641799-927d31d6-8de6-4a96-aace-352f449762f3.png
Ubuntu Server 16.041582545639602-0824021e-68b9-40db-a62d-a16b0954fdc2.png
公共預覽版
Ubuntu Server 18.041582545639994-31a72a69-bd9c-4f1d-acb1-c68ea6e6eb40.png
公共預覽版
Windows 10 IoT 核心版內部版本 177631582545641911-f8af1a8f-df6b-4664-b2e1-0ce3e183f705.png

Windows 10 IoT 企業版內部版本 177631582545639451-f1ac5d48-cc60-48b5-90cc-330e9be9aa51.png

Windows Server 2019 內部版本 177631582545639505-14619ee9-de11-4461-bc0f-e66f16b332fe.png

Windows Server IoT 2019 內部版本 177631582545639406-8ad34add-6b38-485e-961b-aeddc73a2385.png

 

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

操作系統AMD64ARM32v7ARM64
CentOS 7.51582545639527-39aff559-3e3d-4399-91ba-58b0b73db5d7.png1582545639302-03652be2-b0d2-4a55-bc86-290621668837.png1582545639377-af51ebc8-90e0-4c92-99a4-b6d342e2fafb.png
Debian 81582545639494-05ed6d82-6822-431e-8913-ffdf6e6a1612.png1582545639480-f6ba1f6e-11b5-4590-be0c-a22417ea7ab7.png1582545640240-be48cc1e-d6be-4842-9a15-2713654232c9.png
Debian 91582545641071-a23491ee-aae5-4df9-accf-ced1d17d684e.png1582545639363-2ce8dfd6-c783-4183-b8f5-b9e2dd49a9f4.png1582545639513-dcf72a08-2f13-4739-a208-c2df7168d68d.png
Debian 10 11582545640916-29c2a501-a153-4dcc-8c5d-93543633d3d0.png1582545639450-5c425ff9-9266-4886-b3ca-ab2f840aeca8.png1582545640168-ad3ab0ee-8e22-40c7-9a24-47f02bd021cd.png
Mentor Embedded Linux Flex OS1582545640207-0466443a-fce3-482d-9524-99e13c2551c8.png1582545639506-af86932f-0536-4196-b8df-bfd43b21f775.png1582545639403-98574199-71f9-4507-bf64-9ca2641a68fd.png
Mentor Embedded Linux Omni OS1582545639383-5f62abde-f5c2-4446-8b7d-70ec6271cf21.png
1582545639611-15778f12-5e2c-404a-b6f8-69218c3ab6ae.png
RHEL 7.51582545639363-58180827-bb4a-4b3b-b100-9065c181d675.png1582545639457-b059b2d5-fb22-4319-9de7-9ccfbf259f38.png1582545639474-d1637085-9ad2-4b32-8923-3777ae2d50e0.png
Ubuntu 16.041582545639442-8742e5e8-311b-4a7b-9c08-e67ae7fa9b6a.png1582545639569-f83cb330-cd2e-4018-a63a-d660c39ea31e.png1582545639416-9ebd5a29-0a41-41fd-9333-76d49d4f7839.png
Ubuntu 18.041582545640105-35a5cb6b-19b0-4af1-984f-46d38fc64946.png1582545641395-48f42012-1cb2-4140-9f0d-739b074224b8.png1582545641016-bddc6ff1-3561-4418-a8be-deb6273226b7.png
Wind River 81582545641274-be029df4-4f3c-40c4-9bf3-4272e44c76c6.png

Yocto1582545640174-b22c3316-984f-4795-b43e-3e73e66ff92c.png1582545639528-b90d1e66-a0b1-4484-ba9f-1e204bb12dd4.png1582545640243-04dd5f20-0bf9-4e15-817e-6f8343527a25.png
Raspbian Buster 1
1582545641296-0f6ee552-2260-469f-afc4-3651473605fb.png1582545639436-1e91dc50-6575-4cdb-92e7-80f50e04d9e7.png

在Azure上準備一臺虛擬機作爲Edge設備使用

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

1582545638398-b4fde02f-6e5f-42d3-97f1-cb69f3b3f2be.png

 

創建Azure IoT Hub,並創建IoT Edge Device

在IoT Hub-IoT Edge中點擊添加IoT Edge設備

1582545638409-d5ac302c-4a71-4bb4-933f-f8f73929ce55.png

輸入設備ID,其餘保持默認,點擊保存

1582545640146-8afe3ace-9ca9-45f6-ab52-8d7141daec05.png

 

在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

1582545638408-b373af18-81fe-4043-9b7d-27599cc03e98.png

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

注意,需要將下載的cab的包重命名爲 Microsoft-Azure-IoTEdge.cab

vc_redist.exe 下載地址:vc_redist.exe

1582545638406-56923434-1b99-451c-8e7e-317b982a5a06.png

然後右鍵拷貝.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 管理員權限先運行上述腳本,如提示重啓,則重啓後需執行如下腳本:

1582545638454-8a772f29-3368-49df-b111-3537aadd79c3.png

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

 

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

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

1582545638237-6d890118-3b47-4eb2-95bd-36a7ac24a9b1.png

使用 如下命令檢查 IoT Runtime 運行狀態:

Get-Service iotedge

1582545638452-b132334f-051f-4a23-9dd7-b7ad4b314d9f.png

使用如下命令檢查當前運行的模塊:

iotedge list

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

1582545639276-41a72fe1-b9ad-4f32-b43c-23e70954d9ff.png

 

在Portal上可以查看IoT Edge 的運行狀態和模塊狀態:

1582545638411-dd322e04-468a-4cd7-a2dc-c31d41a9b1a5.png

 

1582545639250-70d410d3-9fb8-43b1-bd04-98c0e6d8989f.png


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章