日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【转】设备数据通过Azure Functions 推送到 Power BI 数据大屏进行展示

發布時間:2023/12/10 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【转】设备数据通过Azure Functions 推送到 Power BI 数据大屏进行展示 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

設備數據通過Azure Functions 推送到 Power BI 數據大屏進行展示(1.準備工作)

原創?Sean Yu?云計算實戰?2019-12-06

本案例適用于開發者入門理解Azure Functions/ IoT Hub / Service Bus / Power BI等幾款產品。

?

主要實戰的內容為:

?

  • 將設備遙測數據上傳到物聯網中心,

  • 將遙測數據路由到消息中間件的Topic中,

  • 使用Azure Function解析消息中間件Topic中的消息并推送到大屏?。

  • ?

    本文主要是本案例的準備工作,即(第1條和第2條的內容):

    ?

    1.創建IoT Hub:

    ?

    ?

    2.創建Service Bus:

    ?

    ?

    3.?創建IoT Hub 消息路由,將遙測消息路由到Service Bus Topic

    ?

    ?

    本示例中的Python Device 代碼來自于微軟官網,請參照:

    https://docs.azure.cn/zh-cn/iot-hub/quickstart-send-telemetry-python

    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    • ?
    # Copyright (c) Microsoft. All rights reserved.# Licensed under the MIT license. See LICENSE file in the project root for full license information. import randomimport timeimport sys # Using the Python Device SDK for IoT Hub:# https://github.com/Azure/azure-iot-sdk-python# The sample connects to a device-specific MQTT endpoint on your IoT Hub.import iothub_client# pylint: disable=E0611from iothub_client import IoTHubClient, IoTHubClientError, IoTHubTransportProvider, IoTHubClientResultfrom iothub_client import IoTHubMessage, IoTHubMessageDispositionResult, IoTHubError, DeviceMethodReturnValue # The device connection string to authenticate the device with your IoT hub.# Using the Azure CLI:# az iot hub device-identity show-connection-string --hub-name {YourIoTHubName} --device-id MyNodeDevice --output tableCONNECTION_STRING = "your device conn string" # Using the MQTT protocol.PROTOCOL = IoTHubTransportProvider.MQTTMESSAGE_TIMEOUT = 10000 # Define the JSON message to send to IoT Hub.TEMPERATURE = 20.0HUMIDITY = 60MSG_TXT = "{\"temperature\": %.2f,\"humidity\": %.2f}" def send_confirmation_callback(message, result, user_context): print ( "IoT Hub responded to message with status: %s" % (result) ) def iothub_client_init(): # Create an IoT Hub client client = IoTHubClient(CONNECTION_STRING, PROTOCOL) return client def iothub_client_telemetry_sample_run(): try: client = iothub_client_init() print ( "IoT Hub device sending periodic messages, press Ctrl-C to exit" ) while True: # Build the message with simulated telemetry values. temperature = TEMPERATURE + (random.random() * 15) humidity = HUMIDITY + (random.random() * 20) msg_txt_formatted = MSG_TXT % (temperature, humidity) message = IoTHubMessage(msg_txt_formatted) # Add a custom application property to the message. # An IoT hub can filter on these properties without access to the message body. prop_map = message.properties() if temperature > 30: prop_map.add("temperatureAlert", "true") else: prop_map.add("temperatureAlert", "false") # Send the message. print( "Sending message: %s" % message.get_string() ) client.send_event_async(message, send_confirmation_callback, None) time.sleep(3) except IoTHubError as iothub_error: print ( "Unexpected error %s from IoTHub" % iothub_error ) return except KeyboardInterrupt: print ( "IoTHubClient sample stopped" ) if __name__ == '__main__': print ( "IoT Hub Quickstart #1 - Simulated device" ) print ( "Press Ctrl-C to exit" ) iothub_client_telemetry_sample_run()

    總結

    以上是生活随笔為你收集整理的【转】设备数据通过Azure Functions 推送到 Power BI 数据大屏进行展示的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。