我目前正在使用 amqp.net lite使用 mono 从我的树莓派向 azure eventhub 发送消息。
我的连接字符串如下所示:amqps://SendMessage:[url 编码 key ]@[sb 命名空间]
这工作正常,但现在我想改用 SAS token 。 在这种情况下,有效的连接字符串会是什么样子? 到目前为止,我尝试过的任何方法都对我不起作用。
附注我没有使用 Microsoft 的官方 NuGet 包,因为它不适用于单声道
最佳答案
amqps://[SharedAccessKeyName]:[url 编码的 SharedAccessKey]@[sb 命名空间]
SharedAccessKeyName 和 SharedAccessKey 是从门户获取的策略名称和 token 。
string eventhubHostFormat = "amqps://{0}:{1}@{2}.servicebus.windows.net";
var address = new Address(string.Format(eventhubHostFormat, "your SAS policy name", Uri.EscapeUriString("your SAS key"), "your servicebus name"));
var eventHubConnection = new Connection(address);
var eventHubSession = new Session(eventHubConnection);
var eventHubSender = new SenderLink(eventHubSession, "0" /* partition ID */, "your eventhub name");
关于c# - 使用 amqp.net lite 对 azure eventhub 进行 SAS token 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31201096/