尝试创建 Azure 服务总线队列时出现访问错误

Access error trying to create Azure service bus queue

我 运行 在安装了最新版本的 WindowsAzure.ServiceBus NuGet 包的简单控制台应用程序中使用以下代码:

        var connectionString = "Endpoint=sb://<servername>/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=<SharedAccessKey>";
        var queueName = "TestQueue";

        var ns = NamespaceManager.CreateFromConnectionString(connectionString);

        if (!ns.QueueExists(queueName))
            ns.CreateQueue(queueName);

并收到以下错误:

System.UnauthorizedAccessException was unhandled
  HResult=-2147024891
  Message=The remote server returned an error: (401) Unauthorized. InvalidSignature: The token has an invalid signature. TrackingId:<GUID>_G30, SystemTracker:<MyQueue>.servicebus.windows.net

我尝试了很多不同的方法来修复它,包括删除和重新创建整个命名空间。我还验证了 SharedAccessKey 具有正确的声明(即管理)。

更新

早上回来继续排查这个问题后,莫名其妙地开始工作了,所以我想问题已经变成了,这里发生了什么?代码没有改变。钥匙没变。 (糊涂了!)

您在 TrackingId:<GUID>_G30 中遇到的错误表明网关问题 MSFT 支持团队应该能够提供帮助。命名空间管理操作正在通过 HTTPS,我假设你已经打开了它,即没有任何东西阻止它。所以我敢打赌,与 Azure 支持人员交谈,向他们提供 TrackingId 以找出网关拒绝您请求的原因。