我开发了一个azure函数来处理消息进入IoTHub时的解压缩。Azure功能:IoTHub作为输入和输出
功能是连接到IoTHub内置的消息端点,因此它可以像一个EventHub作用。
我想要的功能是将解压后的内容输出回IoTHub,这样我运行的流分析和其他工作就不必连接到不同的端点以继续接收遥测。
似乎有文档围绕Azure的功能和挂钩起来,以IoTHubs相当数量的,但还有一部分是从去年开始,我知道事情已经改变了不少。
这是我目前的连接字符串来读取和写入同一IoTHub:
Endpoint=sb://iothub-ns-34997-5db385cb1f.servicebus.windows.net/;SharedAccessKeyName=iothubowner;SharedAccessKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=;EntityPath=IoTHub
现在我已经设置了输出去IoTHub终点,我得到一个错误
Exception while executing function: Functions.DecompressionJS. Microsoft.Azure.WebJobs.Host: Error while handling parameter _binder after function returned:. Microsoft.ServiceBus: Unauthorized access. 'Send' claim(s) are required to perform this operation. Resource: 'sb://iothub-ns-34997-5db385cb1f.servicebus.windows.net/iothub'. TrackingId:e85de1ed565243bcb30bc622a2cab252_G4, SystemTracker:gateway6, Timestamp:6/22/2017 9:20:16 PM.
所以我想有一些错误的连接字符串,所以我修改它包含/ iothub,例外告诉我使用的,因为端点的其余部分匹配当前的连接字符串。
一旦我更新了连接字符串,并重新运行我得到了一个不同异常的函数:
Exception while executing function: Functions.DecompressionJS. Microsoft.Azure.WebJobs.Host: Error while handling parameter _binder after function returned:. Microsoft.ServiceBus: Invalid EventHub address. It must be either of the following. Sender: <EventHubName>. Partition Sender: <EventHubName>/Partitions/<PartitionNumber>. Partition Receiver: <EventHubName>/ConsumerGroups/<ConsumerGroupName>/Partitions/<PartitionNumber>. TrackingId:ecb290822f494a86a61c21712656ea4c_G0, SystemTracker:gateway6, Timestamp:6/22/2017 8:44:14 PM.
所以在这一点上,我认为这个IoTHub端点仅用于阅读的消息,也没有办法将解压缩的内容返回到IoTHub。
我希望有人能证明我错了,帮我配置我的连接字符串,所以我可以有一个闭环,并检索和发送消息,并从IoTHub没有中介。
您不应该公开发布您的访问密钥... – Mikhail
感谢您的领导。我已经通过省略了一些内容修改了访问密钥,但是我编辑了共享访问密钥,因此它不再是实际的密钥。 –
请注意,旧访问密钥仍位于[公共修订历史记录](// stackoverflow.com/posts/44709647/revisions)中。 – halfer