English 中文(简体)
• 如何从电离层、电离层和湖向功能发送工具数据?
原标题:How to send tool data from telemetry Azure IoT Hub to Azure Functions?

I created a room temperature control automation system project based on people s presence using Azure Custom Vision and Raspberry Pi. I have successfully sent DHT11 temperature sensor data, camera sensors for the number of people in the image to Azure IoT Hub. The next step is how to get data from Azure IoT Hub into Azure Functions and add data to the local database. After that, you can also perform on/off actions on the device being monitored.

我期望,在ImpoT Hub获得电离层电离层信息数据后,数据也可通过“功能”接收,数据可添加到当地数据库中,而这一数据功能能够以监控装置的形式/起飞。

I have created an event hub, event in azure-iot-hub and i ve also created a function from local vscode so that the values ​​from the tool can be entered into the my local database. My problem was when doing the create an Azure Functions project step and in point number 4. Run the following command to create a Functions app in this folder. Link reference: https://github.com/microsoft/IoT-For-Beginners/tree/main/2-farm/lessons/5-migrate-application-to-the-cloud#create-a-serverless-application

My program has an error that can t run as shown in the following image. error azure function still error like this. error azure function 2

最佳回答

活动 Hub a>,我们可以从Ipahr=mt=t_mt. 这一职能引发对向“活动湖”上游活动发送的事件的反应。

import logging

from azure.functions import EventHubEvent
from typing import List


def main(events: List[EventHubEvent]):
    for event in events:
        logging.info( Python EventHub trigger processed an event: %s ,
                      event.get_body().decode( utf-8 ))


“enter

“entergraph

enter image description here

www.un.org/Depts/DGACM/index_spanish.htm 当地MySQL的法典:


from typing import List
import json
import logging
import pymysql
from azure.functions import EventHubEvent

# MySQL connection details
MYSQL_HOST =  127.0.0.1 
MYSQL_USER =  root 
MYSQL_PASSWORD =  Password 
MYSQL_DB =  quickstartdb 

def create_table_if_not_exists(cursor):
    # Define your table schema here
    table_schema = """
        CREATE TABLE IF NOT EXISTS event_data2 (
            id INT AUTO_INCREMENT PRIMARY KEY,
            event_data JSON
        )
    """
    cursor.execute(table_schema)

def insert_event_data(cursor, event_data):
    # Insert JSON event data into the table
    insert_query = "INSERT INTO event_data2 (event_data) VALUES (%s)"
    cursor.execute(insert_query, (json.dumps(event_data),))

def main(events: List[EventHubEvent]):
    # Create a MySQL connection
    connection = pymysql.connect(
        host=MYSQL_HOST,
        user=MYSQL_USER,
        password=MYSQL_PASSWORD,
        db=MYSQL_DB,
        charset= utf8mb4 ,
        cursorclass=pymysql.cursors.DictCursor
    )

    try:
        with connection.cursor() as cursor:
            # Create table if not exists
            create_table_if_not_exists(cursor)

            # Process each event
            for event in events:
                event_data = json.loads(event.get_body().decode( utf-8 ))

                # Log the event data
                logging.info( Python EventHub trigger processed an event: %s , event_data)

                # Insert JSON event data into MySQL
                insert_event_data(cursor, event_data)

        # Commit the changes
        connection.commit()

    finally:
        # Close the MySQL connection
        connection.close()

Function Logs: enter image description here

“

<>>MySQL:

enter image description here

www.un.org/Depts/DGACM/index_spanish.htm 另一种方法:

“enterography

“enterography

问题回答

暂无回答




相关问题
Windows Azure WorkerRole response

I am working on an Azure demo to run Powershell in a worker role. In my web role I add the name of the Powershell script which is to be run to a CloudQueue object. I can print the script output to ...

Windows Azure WebRole stuck in a deployment loop

I ve been struggling with this one for a couple of days now. My current Windows Azure WebRole is stuck in a loop where the status keeps changing between Initializing, Busy, Stopping and Stopped. It ...

Getting a token for Windows Azure

We are looking at Windows Azure, but getting a token appears to be hard now, at least that s what I m seeing in web searches. Anyone tried it or know how to accelerate that process? Any idea how long ...

Developing Azure .Net 4.0 Applications

Presently .Net 4.0 is not supported on Azure. This thread indicates that you will not be able to use .Net 4.0 with VS 2010 until it is supported in the cloud. http://social.msdn.microsoft.com I d ...

.NET 4.0 on Windows Azure?

My google-fu is failing me on this one. As a possible solution to Unit Testing .NET 3.5 projects using MStest in VS2010 (but I ve put this in a seperate question because it s kind of unrelated): Is ...

热门标签