若要將資料傳送至 Azure IoT 操作中的本機儲存體,您可以設定資料流程端點。 此設定可讓您指定端點、驗證、資料表和其他設定。
先決條件
建立本機儲存體資料流程端點
使用本機儲存體選項,將資料傳送至本機可用的永續性磁碟區,透過它您可以自 Azure Arc Edge 磁碟區啟用的 Azure 容器儲存體上傳資料。
在操作介面中,選擇數據流端點標籤。
在 [建立新的數據流端點] 下,選取 [ 本機記憶體>新增]。
輸入端點的下列設定:
| 設定 |
描述 |
| 名稱 |
資料流程端點的名稱。 |
| 永續性磁碟區宣告名稱 |
要用於本機儲存體的 PersistentVolumeClaim (PVC) 的名稱。 |
按下 套用 以配置端點。
建立或取代
使用 az iot ops dataflow endpoint create fabric-onelake 命令來建立或取代本機記憶體數據流端點。
az iot ops dataflow endpoint create local-storage --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --pvc-ref <PersistentVolumeClaimName>
--pvc-ref 參數是用於本機儲存體的 PersistentVolumeClaim (PVC) 的名稱。 PVC 必須與數據流端點位於相同的命名空間中。
以下是建立或取代名為 local-storage-endpoint的本機記憶體資料流端點的範例命令:
az iot ops dataflow endpoint create local-storage --resource-group myResourceGroup --instance myAioInstance --name local-storage-endpoint --pvc-ref mypvc
建立或變更
使用 az iot ops dataflow endpoint apply 命令來建立或變更本機記憶體數據流端點。
az iot ops dataflow endpoint apply --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --config-file <ConfigFilePathAndName>
參數 --config-file 是 JSON 組態檔的路徑和檔名,其中包含資源屬性。
在此範例中,假設名為 local-storage-endpoint.json 的組態檔,其中包含儲存在使用者主目錄中的下列內容:
{
"endpointType": "LocalStorage",
"localStorageSettings": {
"persistentVolumeClaimRef": "<PersistentVolumeClaimName>"
}
}
以下是建立名為 local-storage-endpoint的新本機記憶體數據流端點的範例命令:
az iot ops dataflow endpoint apply --resource-group myResourceGroupName --instance myAioInstanceName --name local-storage-endpoint --config-file ~/local-storage-endpoint.json
使用下列內容來建立 Bicep .bicep 檔案。
param aioInstanceName string = '<AIO_INSTANCE_NAME>'
param customLocationName string = '<CUSTOM_LOCATION_NAME>'
param endpointName string = '<ENDPOINT_NAME>'
param persistentVCName string = '<PERSISTENT_VC_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 localStorageDataflowEndpoint 'Microsoft.IoTOperations/instances/dataflowEndpoints@2024-11-01' = {
parent: aioInstance
name: endpointName
extendedLocation: {
name: customLocation.id
type: 'CustomLocation'
}
properties: {
endpointType: 'LocalStorage'
localStorageSettings: {
persistentVolumeClaimRef: persistentVCName
}
}
}
然後,透過 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: LocalStorage
localStorageSettings:
persistentVolumeClaimRef: <PVC_NAME>
然後將資訊清單檔套用至 Kubernetes 叢集。
kubectl apply -f <FILE>.yaml
PersistentVolumeClaim (PV) 必須與 DataflowEndpoint 位於相同的命名空間中。
唯一支援的序列化格式是 Parquet。
使用由 Azure Arc 啟用的 Azure 容器儲存體 (ACSA)
您可以使用本機記憶體數據流端點搭配 Azure Arc 啟用的 Azure Container Storage ,將資料儲存在本機,或將數據傳送至雲端目的地。
本機共用磁碟區
若要寫入本機共用磁碟區,請先根據本機共用邊緣磁碟區的指示來建立 PersistentVolumeClaim (PVC)。
然後,設定您的本機儲存體資料流程端點時,請在 persistentVolumeClaimRef 下輸入 PVC 名稱。
雲端內嵌
若要將資料寫入雲端,請遵循雲端內嵌邊緣磁碟區設定中的指示來建立 PVC,並連結您所需雲端目的地的子磁碟區。
重要事項
別忘了在建立 PVC 之後建立子磁碟區,否則資料流程會無法啟動,而記錄會顯示「唯讀檔案系統」錯誤。
然後,設定您的本機儲存體資料流程端點時,請在 persistentVolumeClaimRef 下輸入 PVC 名稱。
最後,當您建立數據流時, 數據目的地 參數必須符合 spec.path 您在設定期間為子卷建立的參數。
後續步驟
若要深入了解數據流,請參閱 建立數據流。