Closed
Description
I'm attempting to send a message via the python MQTT client, publishing telemetry data to the topic below, with a binary body, and trying to find 'myproperty' in the application properties.:
devices/9999999-99999/messages/events/myproperty=myvalue
I'm not sure where to find the information in the EventHubEvent object. event.iothub_metadata simply contains {}
Related information
function.json
{
"scriptFile": "__init__.py",
"bindings": [
{
"dataType": "binary",
"type": "eventHubTrigger",
"name": "event",
"direction": "in",
"eventHubName": "Main-IoT-Hub",
"connection": "EVENT_HUB_CONNECTION",
"cardinality": "one",
"consumerGroup": "$Default"
}
]
}
python azure function definition
# __init__.py
def main(event):
# do stuff here
Abbreviated code used to send telemetry data (it's not the exact code, but I've tried to include relevant information in here).
from paho.mqtt import client as mqtt
from pathlib import *
device_client = client_create_azure_mqtt() # creates the mqtt client
device_client.connect(host=azure_iot_hub_name + ".azure-devices.net", port=8883)
device_client.loop_start()
datafile = PosixPath('path/to/mybinaryfilename.dat')
payload = datafile.read_bytes()
result = device_client.publish("devices/9999999-99999/messages/events/myproperty=myvalue", payload)
Metadata
Metadata
Assignees
Labels
No labels