2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Azure IoT Hubのメッセージルーティング

Last updated at Posted at 2020-02-01

アーキテクチャ

アーキテクチャ

事前準備

上記の赤色については別の投稿を参照してください。
Raspberry Pi(Python)からAzure IoT Hubへテレメトリーを送信する

Azure IoT Hubのメッセージルーティング

情報定義

resourceGroupName={ResourceGroupName}
iotHubName={IoTHubName}
ioteviceName={IoTDeviceName}
storageAccountName={StorageAccountName}
containerName={ContainerName}
endpointName={EndpointName}
endpointType={EndpointType}
routeName={RouteName}

情報取得

subscriptionID=$(az account show --query id)

Storage Account作成

az storage account create \
 --name $storageAccountName \
 --resource-group $resourceGroup \
 --location $location \
 --sku Standard_LRS

Storage Accountキー取得

storageAccountKey=$(az storage account keys list \
 --resource-group $resourceGroup \
 --account-name $storageAccountName \
 --query "[0].value" | tr -d '"')

Storage Accountコンテナー作成

az storage container create --name $containerName \
 --account-name $storageAccountName \
 --account-key $storageAccountKey \
 --public-access off

Storage Accountの接続情報取得

storageConnectionString=$(az storage account show-connection-string \
 --name $storageAccountName \
 --query connectionString \
 -o tsv)

IoT Hubのエンドポイント作成

az iot hub routing-endpoint create \
 --connection-string $storageConnectionString \
 --endpoint-name $endpointName \
 --endpoint-resource-group $resourceGroup \
 --endpoint-subscription-id $subscriptionID \
 --endpoint-type $endpointType \
 --hub-name $iotHubName \
 --container $containerName \
 --resource-group $resourceGroup \
 --encoding json

IoT Hubのメッセージルーティング作成

az iot hub route create \
 --name $routeName \
 --hub-name $iotHubName \
 --source devicemessages \
 --resource-group $resourceGroup \
 --endpoint-name $endpointName \
 --enabled

https://docs.microsoft.com/en-us/azure/iot-hub/tutorial-routing

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?