我需要使用 Python 将 jsonfiles 从我的文件夹发送到 azure-EventHub
import json
from azure.eventhub import EventHubClient, Sender, EventData
# Address can be in either of these formats:
# "amqps://<URL-encoded-SAS-policy>:<URL-encoded-SAS-key>@<mynamespace>.servicebus.windows.net/myeventhub"
# "amqps://<mynamespace>.servicebus.windows.net/myeventhub"
# SAS policy and key are not required if they are encoded in the URL
ADDRESS = "amqps://xxxxxxxxxxxx.servicebus.windows.net/import"
# SAS policy and key are not required if they are encoded in the URL
USER = "xxx"
KEY = "xxxxxxxxxxxxxx"
# Create an Event Hubs client
client = EventHubClient(ADDRESS, debug=False, username=USER, password=KEY)
# Add a sender to the client
sender = client.add_sender(partition="0")
# Run the Event Hub client
client.run()
# Send jsonfile one by one to the event hub from below folder
sender.send(EventData("C:/Users/shef123/Desktop/"))
我的代码不起作用,因为我刚开始学习 python。任何人都可以帮我解决这个问题。
绝地无双
PIPIONE
相关分类