无法连接azure服务总线主题

时间:2017-12-15 09:01:25

标签: c# azure subscription servicebus

我创建了一个小Poc来发送消息到azure服务总线主题。我的代码正在运行,没有任何异常,但在azure服务总线主题中没有看到消息。 如果有任何人对此有任何想法,请提出解决方案。

课程计划

{
    const string ServiceBusConnectionString
        = "Endpoint=sb://etservicebus.servicebus.windows.net/;SharedAccessKeyName=ServiceBusTopicSubsription;SharedAccessKey=Q4Cc+xP07NN4R0w=";
    const string TopicName = "topic1";
    static ITopicClient topicClient;
    static void Main()
    {
        MainAsync().GetAwaiter().GetResult();

    }

    static async Task MainAsync()
    {
        try
        {
            topicClient = new TopicClient(ServiceBusConnectionString, TopicName);

            // Send messages
            string message = "Testing Message";

            await topicClient.SendAsync(new Message(Encoding.UTF8.GetBytes(message)));
        }
        catch (Exception ex)
        {

            throw;
        }


    }
}

我附上了我的代码和天蓝色门户网站详细信息的快照。

C# Code Azure Portal SnapShot

1 个答案:

答案 0 :(得分:0)

我无法用你提到的代码重现它。如果可以创建新主题或新的servicebus帐户,请使用新的servicebus或新主题并再次尝试。以下是我方面的测试结果。我们也可以使用Azure service bus explorer来检查结果。您还可以从Get started with Service Bus topics获得更多演示代码。

注意:

  • 我从azure门户刷新主题,然后我可以在azure门户网站上获取消息信息。
  • 我使用RootManageSharedAccessKey

enter image description here

相关问题