O Azure IoT Edge Ă© um complemento do Hub IoT que permite processar alguns dos dados e processar eventos localmente em vez de na nuvem, reduzir a quantidade de dados transferidos para a nuvem e manter o sistema em funcionamento quando a conexĂŁo com a nuvem for perdida.
Azure SQL Edge Ă© um mĂłdulo para IoT Edge que permite implementar processamento de dados de streaming, aprendizado de mĂĄquina diretamente em um dispositivo com IoT Edge com baixo consumo de memĂłria.
Inicialmente, o princĂpio da computação em nuvem consistia na transferĂȘncia centralizada de cargas de dispositivos locais para data centers, entĂŁo a prĂłpria ideia de retornar o processamento em nuvem de uma parte dos dados, por assim dizer, "de volta" a um dispositivo terrestre, Ă primeira vista pode nĂŁo parecer totalmente clara. Neste material, descobriremos consistentemente o que isso significa e quais vantagens oferece.
Também configuraremos um Hub IoT no Azure, implantaremos um tempo de execução IoT Edge no Windows 10 IoT e Linux, configuraremos e conectaremos um sensor emulado à nuvem; Vejamos como instalar e configurar o SQL Edge.
Problemas de terminologia
"" â "edge", , , . "" / , .. , , . " " ( "edge computing") , " " " ". " ".
" " â , - ("") . , , , . .
, , , .
:
- . , , , . , "" . 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.