【问题标题】:Unable to connect with azure service bus topics无法连接到 Azure 服务总线主题
【发布时间】:2018-05-29 11:03:38
【问题描述】:

我创建了小型 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

【问题讨论】:

  • 请更新您的问题以包含mvce
  • 您没有等待异步方法调用,因此可能会丢失任何错误。
  • 应用了等待,现在低于错误。
  • 您能否编辑问题并 1)在此处发布代码而不是使用图像,以及 2)在问题中也包含错误消息。更易于所有人阅读。
  • 鉴于错误消息,我建议您检查连接字符串和可能的防火墙问题。

标签: c# azure subscription servicebus


【解决方案1】:

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

注意:

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

【讨论】:

    猜你喜欢
    • 2019-03-05
    • 2019-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-25
    • 2018-10-20
    • 1970-01-01
    相关资源
    最近更新 更多