如何在Windows Azure中创建队列? [英] How to Create Queue in Windows Azure?

查看:132
本文介绍了如何在Windows Azure中创建队列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用低于code创建队列,使用 SharedSecretTokenProvider 。但是我不能够提供的正确值 managerName &安培; managerKey 价值形态的Windows Azure门户。

I am using below code to create queue, using SharedSecretTokenProvider. However I am not able to supply correct values of managerName & managerKey value form windows azure portal.

这会导致HTTP 401 未经授权的例外。我该如何解决这个问题?

This results in Http 401 Unauthorized exception. How do I resolve this error?

const string queueName = "thequeue";
var tokenProvider = TokenProvider.CreateSharedSecretTokenProvider(
    ConfigurationManager.AppSettings["managerName"],
    ConfigurationManager.AppSettings["managerKey"]);

Uri uri = ServiceBusEnvironment.CreateServiceUri("http", "MyNamespace" , string.Empty);
NamespaceManager namespaceManager = new NamespaceManager(uri, tokenProvider);

QueueDescription qd = namespaceManager.CreateQueue(new QueueDescription(queueName)
{
    DefaultMessageTimeToLive = TimeSpan.FromMinutes(15),
    DuplicateDetectionHistoryTimeWindow = TimeSpan.FromMinutes(10),
    LockDuration = TimeSpan.FromMinutes(2),
    EnableBatchedOperations = true,
    EnableDeadLetteringOnMessageExpiration = true,
    RequiresDuplicateDetection = true
});

推荐答案

我这跟你的$​​ C $ C尝试了几次,我才意识到这个问题。您正在使用 SharedSecretTokenProvider 将转到 ACS 想它有一个发行人及关键。既然你要使用的 SAS 你要使用 CreateSharedAccessSignatureTokenProvider 代替。

I had tried this a couple of times with your code before I realized the problem. You are using the SharedSecretTokenProvider which will go to ACS thinking it has an issuer and a key. Since you are trying to use the SAS you'll want to use a CreateSharedAccessSignatureTokenProvider instead.

交换了这一点,并提供密钥和的keyName,你应该是好的。

Swap that out and provide the key and keyName and you should be good.

此外,Viperguynaz是正确的,你应该使用SB,而不是HTTP以及。它没有它到达那里,因为令牌提供正确下降访问,因为它不理解的关键和键名你传递它所认为是发行方和关键的ACS使用了。

Also, Viperguynaz is correct, you should use the "sb" instead of http as well. It was failing before it reached there because the token provider was correctly declining you access since it didn't understand the key and keyname you were passing for what it thought was the issuer and key that ACS uses.

这篇关于如何在Windows Azure中创建队列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆