Azure IoT Edge عبارة عن إضافة إلى IoT Hub تتيح لك معالجة بعض البيانات ومعالجة الأحداث محليًا بدلاً من السحابة وتقليل كمية البيانات المنقولة إلى السحابة والحفاظ على النظام وتشغيله عند فقد الاتصال بالسحابة.
Azure SQL Edge هي وحدة نمطية لـ IoT Edge تتيح لك تنفيذ معالجة البيانات المتدفقة والتعلم الآلي مباشرة على جهاز مزود بإنترنت الأشياء مع استهلاك منخفض للذاكرة.
في البداية ، كان مبدأ الحوسبة السحابية يتألف من النقل المركزي للأحمال من الأجهزة المحلية إلى مراكز البيانات ، وبالتالي فإن فكرة إعادة المعالجة السحابية لجزء من البيانات ، كما كانت ، "رجوعًا" إلى جهاز أرضي ، قد لا تبدو للوهلة الأولى واضحة تمامًا. في هذه المادة ، سنكتشف باستمرار ما يعنيه ذلك والمزايا التي يوفرها.
سنقوم أيضًا بإعداد IoT Hub في Azure ، ونشر وقت تشغيل IoT Edge على نظامي التشغيل Windows 10 IoT و Linux ، وتكوين مستشعر تمت محاكاته وتوصيله بالسحابة ؛ لنلق نظرة على تثبيت وتكوين SQL Edge.
قضايا المصطلحات
"الحافة" هي ورقة تتبع من "الحافة" الإنجليزية ، ربما لم تكن ناجحة تمامًا ، ولكنها راسخة تمامًا. تعني بالضبط "حافة" الجهاز / أجهزة إنترنت الأشياء ، أي الجزء الموجود على الأرض والذي يتصل مباشرة بالسحابة ، ولكنه ليس السحابة نفسها بعد. مصطلح "الحوسبة المتطورة" راسخ بالفعل ، على الرغم من أن "الحوسبة المتطورة" أو "الحوسبة المتطورة" تبدو أكثر نجاحًا. في هذه المادة ، سوف نستخدم المصطلح الراسخ "الحوسبة المتطورة".
" " — , - ("") . , , , . .
, , , .
:
- . , , , . , "" . Azure , , : , , ;
- " " : ( , , ). , , , , , ;
- - -. " ".
" ", :
- " " . : ;
- , .. - ;
- , .. - .
?
IoT Edge , , , : "".
- :
- ;
- ;
- , , .
IoT Edge " ":
IoT Edge , IoT Edge, "". Edge Azure.
, IoT Edge.
, Azure IoT Hub IoT Edge.
IoT Edge
IoT Edge :
- — , Azure, , . IoT Edge, ;
- — IoT Edge ;
- — IoT Edge. , — Azure.
Azure IoT Edge IoT Hub Basic.
IoT Edge
IoT Edge — , Docker- , . . "" Azure , IoT Edge .
"" Azure , , . Azure Marketplace .
Java, .NET Core 2.0, Node.js, C, Python.
, , (Yocto Linux).
IoT Edge
IoT Edge ( , ) . ARM Intel/AMD ( ) Linux Windows, .. .
: Raspberry Pi, , , .
IoT Edge . ( ), .. - , .
:
- , ;
- Azure IoT Edge;
- , IoT Edge ;
- IoT Edge ;
- IoT Edge , , IoT Edge, IoT Edge .
IoT Edge , — " ". ("downstream") , .

IoT Edge
, , . - , , . , .
Azure IoT Edge , :
- - ;
- ;
- " ".

— , IoT Edge. , .
, inputs/inX. IoT Edge IoT Hub, $upstream. SQL- :
FROM <source> WHERE <condition> INTO <sink>
:
- source — , , /messages/modules/{module_id}/outputs/{output_id};
- condition — , ;
- sink — () .
, , , URI .
:
FROM /messages/modules/module1/outputs/*
WHERE sensorType="pressure"
INTO $upstream
, .
"" , Azure.
IoT Edge
-, IoT Edge IoT Hub.
IoT Hub — PaaS , .
IoT Edge , , IoT Hub "" IoT Edge, :
- (transparent) — , IoT Hub HTTP, MQTT, AMQP. "" ;
- (protocol translation) — . , IoT Hub , HTTP, MQTT, AMQP. IoT Edge "" , IoT Hub. IoT Hub IoT Edge;
- (identity translation) — , (.. IoT Edge) , , IoT Hub, , .
:

IoT Edge , , , IoT Hub.
Azure SQL Edge
Azure SQL Edge ( preview) — , IoT Edge. SQL Edge Microsoft SQL Server Database Engine, .. SQL Edge , SQL Server Azure SQL Database. , T-SQL.
SQL Edge Azure Marketplace : , , 8 64 , (developer), 4 32 .

SQL Edge :
- , Azure Stream Analytics;
- ONNX (Open Neural Network Exchange). ;
- Azure Blob storage Azure Data Factory Azure SQL Database;
- , .
Azure SQL Edge preview, SQL Server.
, , IoT Edge .
IoT Edge Linux, Windows 10, , Windows 10 IoT Enterprise LTSC. IoT Edge
Windows 10 IoT Enterprise LTSC (Long-term Servicing Channel) — . 10 , , , , , . . (https://www.quarta-embedded.ru/we/10/, https://habr.com/ru/company/quarta/blog/279521/), 3 "" .
Windows 10 x64, 1809 ( 17763). Moby, IoT Edge, . ( 2020) Windows LTSC.
IoT Edge, . , , , , .
Azure, . , .
Cloud Shell :

, . , .
Bash.
Azure IoT:
az extension add --name azure-iot
az account list-locations -o Table
, West Europe. , . , .
rg-aziotedge-test ,
az group create --name rg-aziotedge-test --location westeurope -o json
IoT Hub, , iothub-test-{id}, {id} , , , .. XXYYMMDD, iothub-test-if200810. id , {id}.
IoT Hub :
az iot hub create --name iothub-test-{id} -g rg-aziotedge-test --sku S1 --location westeurope -o json
IoT Hub IoT Edge edge1:
az iot hub device-identity create --device-id edge1 --edge-enabled --hub-name iothub-test-{id} --auth-method shared_private_key
, IoT Hub, :
az iot hub device-identity show-connection-string --device-id edge1 --hub-name iothub-test-{id}
JSON .
, Azure. Resource Groups, rg-aziotedge-test. IoT Hub .
Automatic Device Management IoT Edge IoT Edge. Primary Connection String, .
Windows 10
Windows 10, :
- IoT Edge Azure, , ;
- Windows 10 .
. VirtualBox .
Windows 10 Enterprise LTSC 2019 (1809) . , .
"ISO — LTSC"
Windows. , (Nested) . .
Azure, :
az vm create --resource-group rg-aziotedge-test --name EdgeVM --image MicrosoftWindowsDesktop:Windows-10:rs5-pro:latest --admin-username azureuser --admin-password {password} --size Standard_DS1_v2
{password} — .
RDP.
Windows 10 , . PowerShell x64 .
, .
, 64- PowerShell,
(Get-Process -Id $PID).StartInfo.EnvironmentVariables["PROCESSOR_ARCHITECTURE"]
, Windows IoT Edge, , Moby IoT Edge:
. {Invoke-WebRequest -useb https://aka.ms/iotedge-win} | Invoke-Expression; Deploy-IoTEdge
, .
PowerShell x64 . IoT Edge, :
. {Invoke-WebRequest -useb https://aka.ms/iotedge-win} | Invoke-Expression; `
Initialize-IoTEdge -ContainerOs Windows
. , ( ).
, IoT Edge ,
Get-Service iotedge
:
. {Invoke-WebRequest -useb https://aka.ms/iotedge-win} | Invoke-Expression; Get-IoTEdgeLog
, IoT Edge,
iotedge list
, .
IoT Edge IoT Hub.
IoT Edge
. , Marketplace.
Azure Marketplace, .
Azure IoT Hub Automatic Device Management IoT Edge. edge1.
Set Modules.

IoT Edge Modules Add Marketplace Module .

Simulated Temperature Sensor .
, SimulatedTemperatureSensor , (Desired status) running.
Next: Routes.
, Routes, . , IoT Hub. -. .
route IoT Hub ($upstream). SimulatedTemperatureSensorToIoTHub , Marketplace. SimulatedTemperatureSensor IoT Hub. , , . .

Next: Review + create, .
Review + create JSON, , IoT Edge. , SimulatedTemperatureSensor , edgeAgent, edgeHub. Create.
: IoT Edge , - . IoT Hub . , . (, , .. ) , . , IoT Edge, , . , Refresh , running, :

Windows 10 PowerShell x64 .
, , , ,
iotedge list

, :
iotedge logs SimulatedTemperatureSensor -f
, : .
Ctrl+C, .
Azure Cloud Shell. , IoT Hub:
az iot hub monitor-events --hub-name iothub-test-{id} --device-id edge1
{id} , .
, IoT Hub , Ctrl+C, .
, Windows 10. , 500 . PowerShell:
iotedge restart SimulatedTemperatureSensor
, , , :
To change this, set the environment variable MessageCount to the number of messages that should be sent (set it to -1 to send unlimited messages).
, . ("registry"), IoT Edge , .
Azure
"" Azure:
- Azure Functions ( )
- Azure Stream Analytics ( )
- Azure Machine Learning ( "")
- Azure Custom Vision ( )
- Azure SQL Server ( "")
Stream Analytics. , "" IoT Edge.
Stream Analytics "" "", . , Stream Analytics Azure, IoT Edge .
, , 30- . 70 , , - .
:

Azure Stream Analytics. Azure, :
- Azure Create a resource, Storage, Storage account.
- : Resource group: rg-aziotedge-test, Name: asatest{id}, Region: West Europe, Replication: LRS, .
- Review + create, Create.
Stream Analytics:
- Azure Create a resource, Internet of Things, Stream Analytics job.
- : Job name: asa-iotedge-test, Resource group: rg-aziotedge-test, Location: West Europe, Hosting environment: Edge.
- Create. Go to resource.
- Configure Storage account settings, Add storage account , (asatest{id}). Container ( , , asa) Save.
Stream Analytics:
- Job topology Inputs, Add stream input, Edge Hub. Input alias temperature, Event serialization format: JSON, Encoding: UTF-8, Event compression type: None. Save.
- Output alert, .
Job Topology Query :
SELECT
'reset' AS command
INTO
alert
FROM
temperature TIMESTAMP BY timeCreated
GROUP BY TumblingWindow(second,30)
HAVING Avg(machine.temperature) > 70
Save query.
reset alert, 70 30- .
IoT Edge.
- Azure IoT Edge.
- Set modules, Add Azure Stream Analytics Module asa-iotedge-test. Save.
, , . Cancel. Routes.
:
| alertsToCloud | FROM /messages/modules/asa-iotedge-test/* INTO $upstream |
| alertsToReset | FROM /messages/modules/asa-iotedge-test/* INTO BrokeredEndpoint("/modules/SimulatedTemperatureSensor/inputs/control") |
| telemetryToAsa | FROM /messages/modules/SimulatedTemperatureSensor/* INTO BrokeredEndpoint("/modules/asa-iotedge-test/inputs/temperature") |
Stream Analytics, — IoT Hub.
Review + Create, Create. (Refresh), , asa-iotedge-test .
, , Windows 10 SimulatedTemperatureSensor:
iotedge restart SimulatedTemperatureSensor
reset, ( - ).
iotedge logs -f SimulatedTemperatureSensor
, Ctrl+C.

IoT Edge , IoT Edge :
- (downstream) . IoT Hub;
- IoT Hub ;
- , IoT Hub.
:
- . IoT Edge . , , IoT Edge, - . IoT Edge. , Manage Child Devices Cloud Shell.
- IoT Hub. IoT Edge Azure. , IoT Edge , IoT Hub.
- . ( ) IoT Edge , IoT Hub. IoT Edge. timeToLiveSecs $edgeHub. — 68 , .. , IoT Edge. — 2 .
- IoT Hub. IoT Hub. .
, IoT Edge , "" IoT Edge, .
, IoT Edge SimulatedTemperatureSensor . PowerShell:
iotedge restart SimulatedTemperatureSensor
Cloud Shell IoT Edge:
az iot hub monitor-events --hub-name iothub-test-{id} --device-id edge1
, , .
Cloud Shell , , , .
SQL Edge
SQL Edge preview Linux, Linux- Azure IoT Edge.
, IoT Edge. ,
IoT Edge , Cloud Shell :
az iot hub device-identity create --device-id edge2 --edge-enabled --hub-name iothub-test-{id} --auth-method shared_private_key
az iot hub device-identity show-connection-string --device-id edge2 --hub-name iothub-test-{id}
.
, {password} . .
az vm create --resource-group rg-aziotedge-test --name vm-edge2 --image microsoft_iot_edge:iot_edge_vm_ubuntu:ubuntu_1604_edgeruntimeonly:latest --admin-username azureuser --admin-password {password} --size Standard_DS1_v2 --authentication-type password
Cloud Shell:
ssh azureuser@{publicIpAddress}
{publicIpAddress} — .
yes. . Ubuntu, .
, IoT Edge ,
iotedge version
IoT Edge 1.0.9, , :
curl -L https://github.com/Azure/azure-iotedge/releases/download/1.0.9/libiothsm-std_1.0.9-1_ubuntu16.04_amd64.deb -o libiothsm-std.deb && sudo dpkg -i ./libiothsm-std.deb
curl -L https://github.com/Azure/azure-iotedge/releases/download/1.0.9/iotedge_1.0.9-1_ubuntu16.04_amd64.deb -o iotedge.deb && sudo dpkg -i ./iotedge.deb
, N ( ).
IoT Edge:
systemctl restart iotedge
, .
IoT Edge IoT Hub,
sudo /etc/iotedge/configedge.sh "{ }"
. .
SQL Edge IoT Edge.
- Azure Create a resource.
- Search the Marketplace Azure SQL Edge Enter.
- Azure SQL Edge — Preview , Developer Create.
- Target Devices for IoT Edge Module : Subscription: , IoT Hub: iothub-test-{id}, IoT Edge Device Name: edge2. Create.
- Set Modules on device AzureSQLEdgePreview.
- Environment Variables . . SA_PASSWORD: ( ), MSSQL_LCID: SQL Server (1049 ), MSSQL_COLLATION: ( ).
- Module Settings Restart Policy: always Desired Status: running. Update.
- Review + create, Create.
- IoT Edge .
1433 SQL Edge. :
- Azure rg-aziotedge-test.
- vm-edge2NSG. .
- Settings Inbound security rules, Add.
- Destination port ranges 1433, Protocol: TCP, Name: SQL, Action: Allow. . Add.
SQL Edge . , SQL Edge IoT Edge. SQL Edge .
- Azure Data Studio.
- Start New Connection.
- Server: IP- . Authentication type: SQL Login, User name: sa, Password: SQL Edge, . Connect.
:

New Query :
SELECT @@VERSION
Run Results :

:
CREATE DATABASE TestDatabase;
. , , TestDatabase :

CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID));
Run. , :

T-SQL, .
, SQL Edge SQL Server. . , SQL Edge:
rg-aziotedge-test .
IoT Edge SQL Edge. IoT Edge Windows, Linux.
— , . sergant (at) quarta.ru.