「マイクロソフト系技術情報 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。
Azure IoT Edgeの様々なモジュールをデプロイしていくチュートリアル。
Azure IoT Hubの作成は、Azure IoT Hubチュートリアルへ。
WindowsでAzure IoT EFLOWと言うエミュレータを使用するか、
ARMテンプレートでLinuxのAzureVMをデプロイして試すか、2通りの方法がある。
az iot hub create --resource-group XXXX --name XXXX --sku F1 --partition-count 2
curl https://packages.microsoft.com/config/ubuntu/18.04/multiarch/prod.list > ./microsoft-prod.list sudo mv ./microsoft-prod.list /etc/apt/sources.list.d/ curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg sudo mv ./microsoft.gpg /etc/apt/trusted.gpg.d/ sudo apt-get update sudo apt-get install -y moby-engine moby-cli sudo apt-get install -y iotedge sudo vi /etc/iotedge/config.yaml sudo systemctl restart iotedge systemctl status iotedge sudo iotedge listその後、コンフィグ手順は下記参照。
いずれもWindowsでAzure IoT EFLOWと言うエミュレータを使用する。
ここでは、サポート範囲の広いVisual Studio Code を使用した手順のみ実施する。
pip list pip freeze > uninstall.txt pip uninstall -y -r uninstall.txt pip install -U iotedgedev
デプロイにContainer RegistryとしてAzure Container Registryを使う。
mkdir iotedgesolution cd iotedgesolution iotedgedev solution init --template csharp
ココのシェルはVSCodeのGitBash?ターミナルで実行する。
az login AcrName=osscjpdevinfra echo $AcrName RegistryName=$(az acr show --name $AcrName --query loginServer --output tsv) echo $RegistryName Password=$(az acr credential show --name $RegistryName --query "passwords[0].value" | sed 's/"//g') echo $Password az acr login -n $RegistryName docker login $RegistryName -u $AcrName -p $Password
subscriptionID=$(az account show --query id --output tsv) userPrincipalName=$(az ad signed-in-user show --query userPrincipalName --output tsv) location=westus2 hmsRgName=HmsRG iotHubName=OsscJpDevInfra iotEdgeID=myedge1 hubConnectionString=$( \ az iot hub connection-string show \ -n $iotHubName \ --key primary \ --query connectionString -o tsv) docker build --rm -f "./modules/filtermodule/Dockerfile.amd64.debug" -t osscjpdevinfra.azurecr.io/filtermodule:0.0.1-amd64 "./modules/filtermodule" docker push osscjpdevinfra.azurecr.io/filtermodule:0.0.1-amd64 az iot edge set-modules --hub-name $iotHubName --device-id $iotEdgeID --content ./deployment.template.json --login $hubConnectionString
ここでは、
以下のVSCode拡張をインストールしておく。
https://www.youtube.com/@motojindotcom
- モジュールを開発する
- Visual Studio Code を使用して IoT Edge モジュールを開発する
https://learn.microsoft.com/ja-jp/azure/iot-edge/tutorial-develop-for-linux- Visual Studio 2022 を使用して Azure IoT Edge 用のモジュールを開発してデバッグする
https://learn.microsoft.com/ja-jp/azure/iot-edge/how-to-visual-studio-develop-module- Azure サービスをモジュールとしてデプロイする
- Azure Functions を使用したデータのフィルター処理
https://learn.microsoft.com/ja-jp/azure/iot-edge/tutorial-deploy-function- Azure Stream Analytics を使用して平均値を見つける
https://docs.microsoft.com/ja-jp/azure/iot-edge/tutorial-deploy-stream-analytics- Custom Vision を使用したイメージの分類
https://learn.microsoft.com/ja-jp/azure/iot-edge/tutorial-deploy-custom-vision- SQLを使用したローカルへのデータの格納
https://learn.microsoft.com/ja-jp/azure/iot-edge/tutorial-store-data-sql-server- ゲートウェイとしての IoT Edge の使用
https://docs.microsoft.com/ja-jp/azure/iot-edge/tutorial-nested-iot-edge- デバイスとモジュールを監視する
https://learn.microsoft.com/ja-jp/azure/iot-edge/tutorial-monitor-with-workbooks