重要
このページには、プレビュー段階にある Kubernetes デプロイ マニフェストを使用して Azure IoT Operations コンポーネントを管理する手順が含まれます。 この機能は、いくつかの制限を設けて提供されているため、運用環境のワークロードには使用しないでください。
ベータ版、プレビュー版、または一般提供としてまだリリースされていない Azure の機能に適用される法律条項については、「Microsoft Azure プレビューの使用条件に関する補足」を参照してください。
Azure IoT Operations で Azure Data Explorer にデータを送信するには、データ フロー エンドポイントを構成できます。 この構成では、宛先エンドポイント、認証方法、テーブル、その他の設定を指定できます。
前提条件
-
Azure IoT Operations のインスタンス
-
Azure Data Explorer クラスター。 「クイック スタート: Azure Data Explorer クラスターとデータベースを作成する」の完全なクラスターに関する手順に従います。 このシナリオでは、"無料クラスター" オプションは機能しません。
Azure Data Explorer データベースを作成する
Azure portal で、Azure Data Explorer の "完全な" クラスターにデータベースを作成します。
データのためのテーブルをデータベース内に作成します。 Azure portal を使用して手動で列を作成することも、[クエリ] タブで KQL を使用することもできます。たとえば、サンプル サーモスタット データのテーブルを作成するには、次のコマンドを実行します。
.create table thermostat (
externalAssetId: string,
assetName: string,
CurrentTemperature: real,
Pressure: real,
MqttTopic: string,
Timestamp: datetime
)
テーブルとデータベースでストリーミング インジェストを有効にします。 クエリ タブで、次のコマンドを実行し、<DATABASE_NAME>
を自分のデータベース名に置き換えます。
.alter database ['<DATABASE_NAME>'] policy streamingingestion enable
または、クラスター全体に対してストリーミング インジェストを有効にします。 「既存のクラスターでストリーミング インジェストを有効にする」を参照してください。
マネージド ID にアクセス許可を割り当てる
Azure Data Explorer のデータ フロー エンドポイントを構成するには、ユーザー割り当てマネージド ID またはシステム割り当てマネージド ID のいずれかを使用することをお勧めします。 この方法は安全であり、認証情報を手動で管理する必要がありません。
Azure Data Explorer データベースが作成された後で、そのデータベースへの書き込みを行うためのアクセス許可が付与されるロールを、Azure IoT Operations マネージド ID に割り当てる必要があります。
システム割り当てマネージド ID を使用する場合は、Azure portal で、Azure IoT Operations インスタンスに移動し、[概要] を選択します。
Azure IoT Operations Arc 拡張機能の後に一覧表示されている拡張機能の名前をコピーします。 たとえば、azure-iot-operations-xxxx7 などです。 システム割り当てマネージド ID は、Azure IoT Operations Arc 拡張機能と同じ名前を使用して、見つけることができます。
- (クラスターではなく) [Azure Data Explorer データベース] 内で、[概要] の下にある [アクセス許可]>[追加] を選択し、続いてロールとして [インジェスター] を選択します。 これにより、Azure Data Explorer データベースへの書き込みに必要なアクセス許可がマネージド ID に付与されます。 詳細については、「ロール ベースのアクセス制御」を参照してください。
-
クラウド接続用に設定されたユーザー割り当てマネージド ID またはシステム割り当てマネージド ID の名前を検索します。 たとえば、azure-iot-operations-xxxx7 などです。
- 続いて [選択] を選択します。
Azure Data Explorer のためのデータ フロー エンドポイントを作成する
操作エクスペリエンスで、[データ フロー エンドポイント] タブを選択します。
[新しいデータ フロー エンドポイントの作成] で、[Azure Data Explorer]>[新規] を選びます。
エンドポイントに関する次の設定を入力します。
設定 |
説明 |
名前 |
データ フロー エンドポイントの名前。 |
ホスト |
<cluster>.<region>.kusto.windows.net 形式の Azure Data Explorer エンドポイントのホスト名。 |
認証方法 |
認証に使用する方式。
[システム割り当てマネージド ID] または [ユーザー割り当てマネージド ID] を選択します。 |
クライアント ID |
ユーザー割り当てマネージド ID のクライアント ID。 "ユーザー割り当てマネージド ID" を使用する場合は必須です。 |
テナント ID |
ユーザー割り当てマネージド ID のテナント ID。 "ユーザー割り当てマネージド ID" を使用する場合は必須です。 |
[適用] を選択してエンドポイントをプロビジョニングします。
作成または置換
az iot ops データフロー エンドポイント create adls コマンドを使用して、Azure Data Explorer データ フロー エンドポイントを作成または置き換えます。
az iot ops dataflow endpoint create adx --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --host <ClusterName> --database <DatabaseName>
--host
パラメーターは、<cluster>.<region>.kusto.windows.net
形式の Azure Data Explorer クラスターのホスト名です。
--database
パラメーターは、Azure Data Explorer データベースの名前です。
adx-endpoint という名前の Azure Data Explorer データ フロー エンドポイントを作成または置き換えるコマンドの例を次に示します。
az iot ops dataflow endpoint create adx --resource-group myResourceGroup --instance myAioInstance --name adx-endpoint --host myadxcluster.eastus.kusto.windows.net --database mydatabase
作成または変更
az iot ops データフロー エンドポイント apply コマンドを使用して、Azure Data Explorer データ フロー エンドポイントを作成または変更します。
az iot ops dataflow endpoint apply --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --config-file <ConfigFilePathAndName>
--config-file
パラメーターは、リソース プロパティを含む JSON 構成ファイルのパスとファイル名です。
この例では、ユーザーのホーム ディレクトリに格納されている次のコンテンツを含む adx-endpoint.json
という名前の構成ファイルを想定しています。
{
"endpointType": "DataExplorer",
"dataExplorerSettings": {
"authentication": {
"method": "SystemAssignedManagedIdentity",
"systemAssignedManagedIdentitySettings": {}
},
"batching": {
"latencySeconds": 60,
"maxMessages": 100000
},
"host": "https://<cluster>.<region>.kusto.windows.net",
"database": "<DatabaseName>"
}
}
adx-endpoint という名前の新しい Azure Data Explorer データ フロー エンドポイントを作成するコマンドの例を次に示します。
az iot ops dataflow endpoint apply --resource-group myResourceGroupName --instance myAioInstanceName --name adx-endpoint --config-file ~/adx-endpoint.json
次の内容を含む Bicep .bicep
ファイルを作成します。
param aioInstanceName string = '<AIO_INSTANCE_NAME>'
param customLocationName string = '<CUSTOM_LOCATION_NAME>'
param endpointName string = '<ENDPOINT_NAME>'
param hostName string = 'https://<cluster>.<region>.kusto.windows.net'
param databaseName string = '<DATABASE_NAME>'
resource aioInstance 'Microsoft.IoTOperations/instances@2024-11-01' existing = {
name: aioInstanceName
}
resource customLocation 'Microsoft.ExtendedLocation/customLocations@2021-08-31-preview' existing = {
name: customLocationName
}
resource adxEndpoint 'Microsoft.IoTOperations/instances/dataflowEndpoints@2024-11-01' = {
parent: aioInstance
name: endpointName
extendedLocation: {
name: customLocation.id
type: 'CustomLocation'
}
properties: {
endpointType: 'DataExplorer'
dataExplorerSettings: {
host: hostName
database: databaseName
authentication: {
// See available authentication methods section for method types
// method: <METHOD_TYPE>
}
}
}
}
次に、Azure CLI を使用してデプロイします。
az deployment group create --resource-group <RESOURCE_GROUP> --template-file <FILE>.bicep
次の内容を含む Kubernetes マニフェスト .yaml
ファイルを作成します。
apiVersion: connectivity.iotoperations.azure.com/v1
kind: DataflowEndpoint
metadata:
name: <ENDPOINT_NAME>
namespace: azure-iot-operations
spec:
endpointType: DataExplorer
dataExplorerSettings:
host: 'https://<cluster>.<region>.kusto.windows.net'
database: <DATABASE_NAME>
authentication:
# See available authentication methods section for method types
# method: <METHOD_TYPE>
次に、このマニフェスト ファイルを Kubernetes クラスターに適用します。
kubectl apply -f <FILE>.yaml
使用可能な認証方法
Azure Data Explorer エンドポイントでは、次の認証方法を使用できます。
システム割り当てマネージド ID
データ フロー エンドポイントを構成する前に、Azure Data Explorer データベースに対する書き込みアクセス許可が付与されるロールを Azure IoT Operations マネージド ID に割り当てます。
- Azure portal で、Azure IoT Operations インスタンスに移動し、[概要] を選択します。
-
Azure IoT Operations Arc 拡張機能の後に一覧表示されている拡張機能の名前をコピーします。 たとえば、azure-iot-operations-xxxx7 などです。
- (クラスターではなく) [Azure Data Explorer データベース] に移動し、[概要] の下にある [アクセス許可]>[追加] を選択し、続いて適切なロールを選択します。
- システム割り当てマネージド ID の名前を検索します。 たとえば、azure-iot-operations-xxxx7 などです。
-
[選択] を選択します。
次に、システム割り当てマネージド ID の設定を使用してデータ フロー エンドポイントを構成します。
操作エクスペリエンスのデータ フロー エンドポイント設定ページで、[基本] タブを選択し、[認証方法]>[システム割り当てマネージド ID] を選択します。
作成または置換
az iot ops データフロー エンドポイント create adls コマンドを使用して、Azure Data Explorer データ フロー エンドポイントを作成または置き換えます。
az iot ops dataflow endpoint create adx --auth-type SystemAssignedManagedIdentity --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --host <ClusterName> --database <DatabaseName>
--host
パラメーターは、<cluster>.<region>.kusto.windows.net
形式の Azure Data Explorer クラスターのホスト名です。
--database
パラメーターは、Azure Data Explorer データベースの名前です。
adx-endpoint という名前の Azure Data Explorer データ フロー エンドポイントを作成または置き換えるコマンドの例を次に示します。
az iot ops dataflow endpoint create adx --auth-type SystemAssignedManagedIdentity --resource-group myResourceGroup --instance myAioInstance --name adx-endpoint --host myadxcluster.eastus.kusto.windows.net --database mydatabase
作成または変更
az iot ops データフロー エンドポイント apply コマンドを使用して、Azure Data Explorer データ フロー エンドポイントを作成または変更します。
az iot ops dataflow endpoint apply --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --config-file <ConfigFilePathAndName>
--config-file
パラメーターは、リソース プロパティを含む JSON 構成ファイルのパスとファイル名です。
この例では、ユーザーのホーム ディレクトリに格納されている次のコンテンツを含む adx-endpoint.json
という名前の構成ファイルを想定しています。
{
"endpointType": "DataExplorer",
"dataExplorerSettings": {
"authentication": {
"method": "SystemAssignedManagedIdentity",
"systemAssignedManagedIdentitySettings": {}
},
"batching": {
"latencySeconds": 60,
"maxMessages": 100000
},
"host": "https://<cluster>.<region>.kusto.windows.net",
"database": "<DatabaseName>"
}
}
adx-endpoint という名前の新しい Azure Data Explorer データ フロー エンドポイントを作成するコマンドの例を次に示します。
az iot ops dataflow endpoint apply --resource-group myResourceGroupName --instance myAioInstanceName --name adx-endpoint --config-file ~/adx-endpoint.json
dataExplorerSettings: {
authentication: {
method: 'SystemAssignedManagedIdentity'
systemAssignedManagedIdentitySettings: {}
}
}
dataExplorerSettings:
authentication:
method: SystemAssignedManagedIdentity
systemAssignedManagedIdentitySettings: {}
システム割り当てマネージド ID の対象ユーザーをオーバーライドする必要がある場合は、audience
設定を指定できます。
ほとんどの場合、他の設定を指定する必要はありません。 この構成では、既定の対象ユーザー https://api.kusto.windows.net
を使用してマネージド ID が作成されます。
作成または置換
az iot ops dataflow endpoint create adls コマンドを使用して、Azure Data Explorer データ フロー エンドポイントを作成するか、システム割り当てマネージド ID に置き換えます。
az iot ops dataflow endpoint create adx --auth-type SystemAssignedManagedIdentity --audience https://<cluster>.<region>.kusto.windows.net --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --host <cluster>.<region>.kusto.windows.net --database <DatabaseName>
--host
パラメーターは、<cluster>.<region>.kusto.windows.net
形式の Azure Data Explorer クラスターのホスト名です。
--database
パラメーターは、Azure Data Explorer データベースの名前です。
--audience
パラメーターは、Azure Data Explorer に対して認証するマネージド ID の対象ユーザー URL です。
adx-endpoint
という名前の Azure Data Explorer データ フロー エンドポイントを作成または置換するコマンドの例を次に示します。
az iot ops dataflow endpoint create adx --auth-type SystemAssignedManagedIdentity --audience https://myadxcluster.eastus.kusto.windows.net --resource-group myResourceGroup --instance myAioInstance --name adx-endpoint --host myadxcluster.eastus.kusto.windows.net --database mydatabase
作成または変更
az iot ops dataflow endpoint apply コマンドを使用して、システム割り当てマネージド ID を使用して Azure Data Explorer データ フロー エンドポイントを作成または変更します。
az iot ops dataflow endpoint apply --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --config-file <ConfigFilePathAndName>
--config-file
パラメーターは、リソース プロパティを含む JSON 構成ファイルのパスとファイル名です。
この例では、ユーザーのホーム ディレクトリに格納されている次のコンテンツを含む adx-endpoint.json
という名前の構成ファイルを想定しています。
{
"endpointType": "DataExplorer",
"dataExplorerSettings": {
"authentication": {
"method": "SystemAssignedManagedIdentity",
"systemAssignedManagedIdentitySettings": {
"audience": "https://<cluster>.<region>.kusto.windows.net"
}
},
"batching": {
"latencySeconds": 60,
"maxMessages": 100000
},
"host": "https://<cluster>.<region>.kusto.windows.net",
"database": "<DatabaseName>"
}
}
adx-endpoint
という名前の新しい Azure Data Explorer データ フロー エンドポイントを作成するコマンドの例を次に示します。
az iot ops dataflow endpoint apply --resource-group myResourceGroupName --instance myAioInstanceName --name adx-endpoint --config-file ~/adx-endpoint.json
dataExplorerSettings: {
authentication: {
method: 'SystemAssignedManagedIdentity'
systemAssignedManagedIdentitySettings: {
audience: 'https://<AUDIENCE_URL>'
}
}
}
dataExplorerSettings:
authentication:
method: SystemAssignedManagedIdentity
systemAssignedManagedIdentitySettings:
audience: https://<AUDIENCE_URL>
ユーザー割り当てマネージド ID
認証にユーザー割り当てマネージド ID を使用するには、まず、セキュリティで保護された設定を有効にして Azure IoT Operations を展開する必要があります。 次に、クラウド接続用にユーザー割り当てマネージド ID を設定する必要があります。 詳細については、「Azure IoT Operations の展開でセキュリティで保護された設定を有効にする」を参照してください。
データ フロー エンドポイントを構成する前に、Azure Data Explorer データベースに対する書き込みアクセス許可が付与されるロールをユーザー割り当てマネージド ID に割り当てます。
- Azure portal で、(クラスターではなく) [Azure Data Explorer データベース] に移動し、[概要] の下にある [アクセス許可]>[追加] を選択し、続いて適切なロールを選択します。
- ユーザー割り当てマネージド ID の名前を検索します。
-
[選択] を選択します。
次に、ユーザー割り当てマネージド ID の設定を使用してデータ フロー エンドポイントを構成します。
操作エクスペリエンスのデータ フロー エンドポイント設定ページで、[基本] タブを選択し、[認証方法]>[ユーザー割り当てマネージド ID] を選択します。
該当するフィールドに、ユーザー割り当てマネージド ID のクライアント ID とテナント ID を入力します。
作成または置換
az iot ops dataflow endpoint create adls コマンドを使用して、Azure Data Explorer データ フロー エンドポイントをユーザー割り当てマネージド ID に作成または置き換えます。
az iot ops dataflow endpoint create adx --auth-type UserAssignedManagedIdentity --client-id <ClientId> --tenant-id <TenantId> --scope <Scope> --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --host <cluster>.<region>.kusto.windows.net --database <DatabaseName>
--host
パラメーターは、<cluster>.<region>.kusto.windows.net
形式の Azure Data Explorer クラスターのホスト名です。
--database
パラメーターは、Azure Data Explorer データベースの名前です。
--auth-type
パラメーターは認証方法を指定します。この場合UserAssignedManagedIdentity
。
--client-id
、--tenant-id
、および--scope
パラメーターでは、ユーザー割り当てマネージド ID クライアント ID、テナント ID、およびスコープをそれぞれ指定します。
adx-endpoint
という名前の Azure Data Explorer データ フロー エンドポイントを作成または置換するコマンドの例を次に示します。
az iot ops dataflow endpoint create adx --auth-type UserAssignedManagedIdentity --client-id ClientId --tenant-id TenantId --scope https://api.kusto.windows.net/.default --resource-group myResourceGroup --instance myAioInstance --name adx-endpoint --host myadxcluster.eastus.kusto.windows.net --database mydatabase
作成または変更
az iot ops dataflow endpoint apply コマンドを使用して、ユーザー割り当てマネージド ID を使用して Azure Data Explorer データ フロー エンドポイントを作成または変更します。
az iot ops dataflow endpoint apply --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --config-file <ConfigFilePathAndName>
--config-file
パラメーターは、リソース プロパティを含む JSON 構成ファイルのパスとファイル名です。
この例では、ユーザーのホーム ディレクトリに格納されている次のコンテンツを含む adx-endpoint.json
という名前の構成ファイルを想定しています。
{
"endpointType": "DataExplorer",
"dataExplorerSettings": {
"authentication": {
"method": "UserAssignedManagedIdentity",
"userAssignedManagedIdentitySettings": {
"clientId": "<ClientId>",
"scope": "<Scope>",
"tenantId": "<TenantId>"
}
},
"batching": {
"latencySeconds": 60,
"maxMessages": 100000
},
"host": "https://<cluster>.<region>.kusto.windows.net",
"database": "<DatabaseName>"
}
}
adx-endpoint
という名前の新しい Azure Data Explorer データ フロー エンドポイントを作成するコマンドの例を次に示します。
az iot ops dataflow endpoint apply --resource-group myResourceGroupName --instance myAioInstanceName --name adx-endpoint --config-file ~/adx-endpoint.json
dataExplorerSettings: {
authentication: {
method: 'UserAssignedManagedIdentity'
userAssignedManagedIdentitySettings: {
clientId: '<ID>'
tenantId: '<ID>'
// Optional, defaults to 'https://api.kusto.windows.net/.default'
// scope: 'https://<SCOPE_URL>'
}
}
}
dataExplorerSettings:
authentication:
method: UserAssignedManagedIdentity
userAssignedManagedIdentitySettings:
clientId: <ID>
tenantId: <ID>
# Optional, defaults to 'https://api.kusto.windows.net/.default'
# scope: https://<SCOPE_URL>
ここでは、"scope" は省略可能であり、既定値は https://api.kusto.windows.net/.default
です。 既定のスコープをオーバーライドする必要がある場合は、Bicep または Kubernetes を使用して scope
設定を指定します。
詳細設定
バッチ処理の待機時間やメッセージ数など、Azure Data Explorer エンドポイントの詳細設定を設定できます。
メッセージの最大数と、メッセージが宛先に送信されるまでの最大待機時間を構成するには、batching
設定を使用します。 この設定は、ネットワーク帯域幅を最適化し、宛先への要求数を減らす場合に役立ちます。
フィールド |
説明 |
必須 |
latencySeconds |
メッセージを宛先に送信するまでの最大待機時間 (秒数)。 既定値は 60 秒です。 |
いいえ |
maxMessages |
宛先に送信するメッセージの最大数。 既定値は、100,000 メッセージです。 |
いいえ |
たとえば、メッセージの最大数を 1,000 に構成し、最大待機時間を 100 秒に設定するには、次の設定を使用します。
操作エクスペリエンスで、データ フロー エンドポイントの [詳細] タブを選択します。
az iot ops dataflow endpoint apply コマンドを使用して、詳細設定を使用して Azure Data Explorer データ フロー エンドポイントを作成または変更します。
az iot ops dataflow endpoint apply --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --config-file <ConfigFilePathAndName>
--config-file
パラメーターは、リソース プロパティを含む JSON 構成ファイルのパスとファイル名です。
この例では、ユーザーのホーム ディレクトリに格納されている次のコンテンツを含む adx-endpoint.json
という名前の構成ファイルを想定しています。
{
"endpointType": "DataExplorer",
"dataExplorerSettings": {
"authentication": {
"method": "SystemAssignedManagedIdentity",
"systemAssignedManagedIdentitySettings": {}
},
"batching": {
"latencySeconds": 100,
"maxMessages": 1000
},
"host": "https://<cluster>.<region>.kusto.windows.net",
"database": "<DatabaseName>"
}
}
adx-endpoint という名前の新しい Azure Data Explorer データ フロー エンドポイントを作成するコマンドの例を次に示します。
az iot ops dataflow endpoint apply --resource-group myResourceGroupName --instance myAioInstanceName --name adx-endpoint --config-file ~/adx-endpoint.json
dataExplorerSettings: {
batching: {
latencySeconds: 100
maxMessages: 1000
}
}
dataExplorerSettings:
batching:
latencySeconds: 100
maxMessages: 1000
次のステップ
データ フローの詳細については、「データ フローの作成」を参照してください。