Azure没有将系统属性附加到我的消息上。这会在我尝试将消息路由到Blob存储时产生问题。我需要补充这些:
"contentType":"application/json", "contentEncoding":"utf-8",
在test/properties中,我可以看到设置是正确的,但这是仅用于测试还是消息路由?对此有何想法?
iezvtpos1#
您可以在示例化消息时设置属性:
var messageToSend = new Message(Encoding.UTF8.GetBytes(jsonData)) { ContentType = "application/json", ContentEncoding = "utf-8" };
发送消息的完整示例:
async Task SendToIoTHub(OdtcDataEventArgs eventArgs) { var sensorValues = eventArgs.GetSensorValues(); string jsonData = JsonSerializer.Serialize(sensorValues); var messageToSend = new Message(Encoding.UTF8.GetBytes(jsonData)) { ContentType = "application/json", ContentEncoding = "utf-8" }; if (_deviceClient != null) { await _deviceClient.SendEventAsync(messageToSend).ConfigureAwait(false); } }
1条答案
按热度按时间iezvtpos1#
您可以在示例化消息时设置属性:
发送消息的完整示例: