若要從 Azure IoT 操作將資料傳送至 Microsoft Fabric 即時智慧,您可以設定資料流程端點。 透過此設定,您可以指定目的地端點、認證方式、主題及其他設定。
先決條件
安裝在你的開發機器上的 Azure CLI 版本 2.62.0 或更新版本。 使用 az --version 檢查您的版本,並視需要更新 az upgrade。 更多資訊請參見 安裝 Azure CLI。
Azure CLI 的 Azure IoT 操作 延伸模組。 使用下列命令將延伸模組新增或更新至最新版本:
az extension add --upgrade --name azure-iot-ops
附註
事件串流支援多個輸入來源,其中包括 Azure 事件中樞。 如果您已經有資料流到 Event Hubs,您可以將該資料流帶入 Fabric,如 快速入門:從處理過的資料取得深入解析 中所示。 這篇文章教你如何將即時資料直接流入 Fabric,中間沒有任何跳轉。
擷取自定義端點連線詳細數據
擷取 自定義端點的 Kafka 相容連線詳細數據。 連線詳細資料可用來在 Azure IoT 操作中設定資料流程端點。
此方法使用受管理身份與事件串流進行認證。 在設定資料流端點時,請使用系統指派的管理身份或使用者指派的管理型識別碼。
在 Fabric 入口網站中,於 eventstream 的 來源 區段下前往連線詳細資料。
在自訂端點 的詳細 選區中,選擇 Kafka 協定。
選取 Entra ID 驗證 部分以檢視連線詳細資料。
複製 Bootstrap 伺服器 與 主題名稱 的詳細資訊。 您可以使用這些值來設定資料流端點。
| 設定 |
描述 |
|
Bootstrap 伺服器 |
Bootstrap 伺服器位址用作資料流端點中的主機名稱屬性。 |
|
主題名稱 |
事件中心名稱用作卡夫卡主題,其格式為es_aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb。 |
在 Fabric 入口網站中,於 eventstream 的 來源 區段下前往連線詳細資料。
在自訂端點 的詳細 選區中,選擇 Kafka 協定。
選取 [SAS 金鑰驗證 ] 區段以檢視連線詳細數據。
複製 Bootstrap 伺服器的詳細資訊、 主題名稱及 Connection 字串-主鍵 值。 您可以使用這些值來設定資料流端點。
| 設定 |
描述 |
|
Bootstrap 伺服器 |
Bootstrap 伺服器位址用作資料流端點中的主機名稱屬性。 |
|
主題名稱 |
事件中心名稱用作卡夫卡主題,其格式為es_aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb。 |
|
連接字串 - 主要金鑰 |
具有主索引鍵的連接字串。 |
建立 Fabric 即時智慧資料流程端點
在Azure IoT 操作體驗入口網站中,選擇 Data flow endpoints 標籤。
在 [建立新的數據流端點] 下,選取 [Microsoft Fabric Real-Time Intelligence>New]。
輸入端點的下列設定。
| 設定 |
描述 |
|
Name |
資料流程端點的名稱。 |
|
主機 |
事件串流自訂端點的主機名稱格式為 <bootstrap-server>.servicebus.windows.net:9093。 使用先前記下的啟動程序伺服器位址。 |
|
驗證方法 |
用於驗證的方法。 選擇系統指派管理身份、使用者指派管理身份或 SASL。 |
使用與您希望 Azure IoT 操作 連線至 Fabric 事件資料流自訂端點方式相符的驗證方法:
-
系統指派管理身份:使用Azure IoT 操作 Azure Arc擴充身份與事件串流進行認證。 建立端點之前,請將擴充功能身分識別加入 Fabric 工作區,並授予貢獻者或更高的權限。 欲了解更多,請參閱 系統指派管理身份。
-
使用者指派的託管身分:使用配置為 Azure IoT 操作 雲端連接的使用者指派的託管身分。 建立端點之前,請將使用者指派的受控身分識別加入 Fabric 工作區,並授予貢獻者或更高的權限。 欲了解更多,請參閱 使用者指派管理身份。
-
SASL:使用 Fabric 事件串流的自訂端點連接字串。 此方法需簡單認證與安全層(SASL)設定,並將 Kubernetes 秘密與使用者名稱與密碼值同步。 欲了解更多,請參閱SASL。
選取 [套用] 以佈建端點。
建立或取代
請使用以下 az iot ops dataflow endpoint create fabric-realtime 指令來建立或替換 Real-Time Intelligence 資料流端點:
az iot ops dataflow endpoint create fabric-realtime --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --host "<BootstrapServerAddress>"
請使用以下範例指令建立或替換一個名為 fabric-realtime-endpointReal-Time Intelligence 資料流端點:
az iot ops dataflow endpoint create fabric-realtime --resource-group myResourceGroup --instance myAioInstance --name fabric-realtime-endpoint --host "fabricrealtime.servicebus.windows.net:9093"
建立或變更
請使用下列 az iot ops dataflow endpoint apply 命令來建立或變更 Real-Time Intelligence 資料流端點:
az iot ops dataflow endpoint apply --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --config-file <ConfigFilePathAndName>
參數 --config-file 是包含資源屬性的 JSON 設定檔的路徑與檔案名稱。
在此範例中,假設一個設定檔以以下內容命名 fabric-realtime-endpoint.json ,儲存在使用者的主目錄中:
{
"endpointType": "Kafka",
"kafkaSettings": {
"host": "<BootstrapServerAddress>",
"authentication": {
"method": "Sasl",
"saslSettings": {
"saslType": "Plain",
"secretRef": "<SecretName>"
}
},
"tls": {
"mode": "Enabled"
}
}
}
請使用以下範例指令建立一個新的 Real-Time 智慧資料流端點,名稱為 fabric-realtime-endpoint:
az iot ops dataflow endpoint apply --resource-group myResourceGroupName --instance myAioInstanceName --name fabric-realtime-endpoint --config-file ~/fabric-realtime-endpoint.json
建立包含 .bicep 下列內容的檔案:
param aioInstanceName string = '<AIO_INSTANCE_NAME>'
param customLocationName string = '<CUSTOM_LOCATION_NAME>'
param endpointName string = '<ENDPOINT_NAME>'
param hostName string = '<BOOTSTRAP_SERVER_ADDRESS>'
param secretName string = '<SECRET_NAME>'
resource customLocation 'Microsoft.ExtendedLocation/customLocations@2021-08-31-preview' existing = {
name: customLocationName
}
resource aioInstance 'Microsoft.IoTOperations/instances@2024-11-01' existing = {
name: aioInstanceName
}
resource fabricRealtimeEndpoint 'Microsoft.IoTOperations/instances/dataflowEndpoints@2024-11-01' = {
parent: aioInstance
name: endpointName
extendedLocation: {
name: customLocation.id
type: 'CustomLocation'
}
properties: {
endpointType: 'Kafka'
kafkaSettings: {
host: hostName
authentication: {
method: 'Sasl'
saslSettings: {
saslType: 'Plain' // Or ScramSha256, ScramSha512
secretRef: secretName
}
}
tls: {
mode: 'Enabled'
}
}
}
}
透過 Azure CLI 部署檔案:
az deployment group create --resource-group <RESOURCE_GROUP> --template-file <FILE>.bicep
這很重要
正式生產環境不支援使用 Kubernetes 部署資訊清單,且僅應用於偵錯與測試。
kubectl create secret generic <SECRET_NAME> -n azure-iot-operations \
--from-literal=username='$ConnectionString' \
--from-literal=password='<ConnectionStringPrimaryKey>'
使用下列內容建立 Kubernetes 資訊清單 .yaml 檔案:
apiVersion: connectivity.iotoperations.azure.com/v1
kind: DataflowEndpoint
metadata:
name: <ENDPOINT_NAME>
namespace: azure-iot-operations
spec:
endpointType: Kafka
kafkaSettings:
host: <BOOTSTRAP_SERVER_ADDRESS>
authentication:
method: Sasl
saslSettings:
saslType: Plain # Or ScramSha256, ScramSha512
secretRef: <SECRET_NAME>
tls:
mode: Enabled
將資訊清單檔套用至 Kubernetes 叢集:
kubectl apply -f <FILE>.yaml
可用的驗證方法
以下認證方法可用於 Real-Time 智慧資料流端點。
系統指派的管理身份識別
在設定資料流端點之前,先讓 Azure IoT 操作 管理身份存取包含你事件串流的 Fabric 工作區。 Fabric eventstream 的自訂端點會透過 Fabric 工作區存取權來授權受控身分識別,而不是透過 Azure 資源上的 Azure 入口網站身分識別與存取管理 (IAM)。
- 在Azure入口網站,前往你的Azure IoT 操作實例,選擇Overview。
- 複製 Azure IoT 操作 Arc 擴充功能之後所列的擴充功能名稱。 例如,複製 azure-iot-operations-xxxx7。
- 在 Fabric 中,前往包含你的事件資料流的工作區。
- 選擇「管理存取>」新增人員或群組。
- 搜尋您先前複製的 Azure IoT 操作 Azure Arc 延伸模組身分識別。 一個範例是 azure-iot-operations-xxxx7。
- 將貢獻者或更高的工作區權限指派給該身分識別。
欲了解更多資訊,請參見 Assign Fabric workspace permissions。
請以系統指派的管理身份設定配置資料流端點。
在資料流端點設定頁面的作業體驗索引標籤中,選取 基本 索引標籤,然後在 驗證方法>系統指派的受控識別 中選取。
建立或取代
使用 az IoT Ops 資料流端點,建立 Fabric-Realtime 指令,並將 --auth-type 參數設為 , SystemAssignedManagedIdentity 用於系統指派的管理身份驗證。 在大多數情況下,你不需要特別指定 --audience。 預設對象與端點主機的格式https://<NAMESPACE>.servicebus.windows.net相符。
az iot ops dataflow endpoint create fabric-realtime --auth-type SystemAssignedManagedIdentity --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --host "<BootstrapServerAddress>"
建立或變更
使用 az iot ops dataflow endpoint apply 命令並指定 --config-file 參數。
在此範例中,假設組態檔具有下列內容:
{
"endpointType": "Kafka",
"kafkaSettings": {
"host": "fabricrealtime.servicebus.windows.net:9093",
"authentication": {
"method": "SystemAssignedManagedIdentity",
"systemAssignedManagedIdentitySettings": {}
},
"tls": {
"mode": "Enabled"
}
}
}
kafkaSettings: {
authentication: {
method: 'SystemAssignedManagedIdentity'
systemAssignedManagedIdentitySettings: {}
}
}
這很重要
正式生產環境不支援使用 Kubernetes 部署資訊清單,且僅應用於偵錯與測試。
kafkaSettings:
authentication:
method: SystemAssignedManagedIdentity
systemAssignedManagedIdentitySettings:
{}
使用者指派的受管理的身分識別
若要將使用者指派的受控識別用於驗證,您必須先部署已啟用安全設定的 Azure IoT 操作。 然後,您必須 為雲端連線設定使用者指派的受控識別。 若要深入瞭解,請參閱 在 Azure IoT 作業部署中啟用安全設定。
在設定資料流端點之前,先讓使用者指派的管理身份存取包含你事件串流的 Fabric 工作區。 Fabric eventstream 的自訂端點會透過 Fabric 工作區存取權來授權受控身分識別,而不是透過 Azure 資源上的 Azure 入口網站 IAM。
- 在 Fabric 中,前往包含你的事件資料流的工作區。
- 選擇「管理存取>」新增人員或群組。
- 搜尋您的使用者指定受控識別。
- 將貢獻者或更高的工作區權限指派給該身分識別。
欲了解更多資訊,請參見 Assign Fabric workspace permissions。
以使用者指定的管理身份設定配置資料流端點。
在資料流端點設定頁面的操作體驗標籤中,選擇 「基本 」標籤,然後選擇 「驗證方法>:使用者指派的管理身份」。
建立或取代
使用 az iot ops dataflow endpoint create 命令,並將 --auth-type 參數設定為 UserAssignedManagedIdentity 以用於使用者指派的受控識別驗證。
az iot ops dataflow endpoint create fabric-realtime --auth-type UserAssignedManagedIdentity --client-id <ClientId> --tenant-id <TenantId> --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --host "<BootstrapServerAddress>"
建立或變更
使用 az iot ops dataflow endpoint apply 命令並指定 --config-file 參數。
在此範例中,假設一個設定檔內容如下:
{
"endpointType": "Kafka",
"kafkaSettings": {
"host": "<BootstrapServerAddress>",
"authentication": {
"method": "UserAssignedManagedIdentity",
"userAssignedManagedIdentitySettings": {
"clientId": "<ID>",
"tenantId": "<ID>"
}
},
"tls": {
"mode": "Enabled"
}
}
}
scope 是選用屬性。 如果需要,將其設為 Kafka 代理的對象,例如https://<BootstrapServerAddress>。
kafkaSettings: {
authentication: {
method: 'UserAssignedManagedIdentity'
userAssignedManagedIdentitySettings: {
clientId: '<CLIENT_ID>'
tenantId: '<TENANT_ID>'
// Optional
// scope: 'https://<SCOPE_URL>'
}
}
...
}
這很重要
正式生產環境不支援使用 Kubernetes 部署資訊清單,且僅應用於偵錯與測試。
kafkaSettings:
authentication:
method: UserAssignedManagedIdentity
userAssignedManagedIdentitySettings:
clientId: <CLIENT_ID>
tenantId: <TENANT_ID>
# Optional
# scope: https://<SCOPE_URL>
SASL
若要使用 SASL 進行認證,請指定 SASL 認證方法,並設定 SASL 類型及包含 SASL 憑證的密鑰名稱的密鑰引用。
我們建議你使用 Azure Key Vault 將 連接字串 同步到 Kubernetes 叢集,讓資料流能參考它。 必須啟用安全設定,才能透過操作體驗的網頁介面來配置此端點。
在資料流端點設定頁面的操作體驗分頁,選擇「基本」分頁,然後選擇「認證方法>SASL」。
輸入端點的下列設定:
| 設定 |
描述 |
|
SASL 類型 |
要使用的 SASL 驗證類型。 若為 Fabric 自訂端點,請選取 Plain。 |
|
同步的秘密名稱 |
輸入同步機密的名稱。 即會叢集上建立具有此名稱的 Kubernetes 祕密。 |
|
token secret 的使用者名稱參考 |
用於 SASL 驗證的使用者名稱參考或權杖密碼。 |
|
權杖秘密的密碼參考 |
用於 SASL 驗證的密碼參考或權杖密碼。 |
選擇 Add reference 以建立新的金鑰保存庫參考,或選擇現有的 金鑰保存庫 參考作為使用者名稱與密碼參考:
建立或取代
使用 az iot ops dataflow endpoint create 命令,並將 --auth-type 參數設定 Sasl 為 進行 SASL 驗證。
az iot ops dataflow endpoint create fabric-realtime --auth-type Sasl --sasl-type <SaslType> --secret-name <SecretName> --resource-group <ResourceGroupName> --instance <AioInstanceName> --name <EndpointName> --host "<BootstrapServerAddress>"
建立或變更
使用 az iot ops dataflow endpoint apply 命令並指定 --config-file 參數。
在此範例中,假設一個設定檔內容如下:
{
"endpointType": "Kafka",
"kafkaSettings": {
"host": "<BootstrapServerAddress>",
"authentication": {
"method": "Sasl",
"saslSettings": {
"saslType": "<SaslType>",
"secretRef": "<SecretName>"
}
},
"tls": {
"mode": "Enabled"
}
}
}
kafkaSettings: {
authentication: {
method: 'Sasl'
saslSettings: {
saslType: 'Plain' // Or ScramSha256, ScramSha512
secretRef: '<SECRET_NAME>'
}
}
}
這很重要
正式生產環境不支援使用 Kubernetes 部署資訊清單,且僅應用於偵錯與測試。
kubectl create secret generic <SECRET_NAME> -n azure-iot-operations \
--from-literal=username='$ConnectionString' \
--from-literal=password='<ConnectionStringPrimaryKey>'
kafkaSettings:
authentication:
method: Sasl
saslSettings:
saslType: Plain # Or ScramSha256, ScramSha512
secretRef: <SECRET_NAME>
支援的 SASL 類型:
Plain
ScramSha256
ScramSha512
祕密必須與 Kafka 資料流程端點位於相同命名空間中。 秘密必須同時包含使用者名稱和密碼作為鍵值配對。
進階設定
此端點的進階設定與 Event Hubs 端點的進階設定相同。
後續步驟