开发者

Windows Azure - Web Role cannot access Local Development Queue Storage

I have a class library that is shared between multiple Role projects in my solution. Two of these projects are a Web Role and a Worker Role.

They each have the same Configuration Setting:

<Setting name="QueueConnectionString" value="UseDevelopmentStorage=true" />

each of them is making a call to this function:

public static void AddMessage(string Message)
    {
        var account = CloudStorageAccount.DevelopmentStorageAccount;
        ServicePoint queueServicePoint = ServicePointManager.FindServicePoint(account.QueueEndpoint);
        queueServicePoint.UseNagleAlgorithm = false;
        var client = account.CreateCloudQueueClient();
        var queue = client.GetQueueReference(DefaultRoleInst开发者_运维问答anceQueueName);
        queue.CreateIfNotExist();
        queue.AddMessage(new CloudQueueMessage(Message));
 }

When this executes in the Worker Role, it works without any issues; I've confirmed proper reads and writes of Queue messages. When it executes in the Web Roles, the call to queue.CreateifNotExist() crashes with the error "Response is not available in this context". I've tried searching for information on what could be causing this but so far my search efforts have been fruitless. Please let me know if there's any additional information I can include.


ok, so after a lot more work, I determined that it was because i was calling it from within the Global.asax Application_Start.

I moved this to my WebRole.cs OnStart() function and it works properly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜