gpt4 book ai didi

azure - Windows Azure - Web 角色无法访问本地开发队列存储

转载 作者:行者123 更新时间:2023-12-02 08:57:42 26 4
gpt4 key购买 nike

我有一个在我的解决方案中的多个角色项目之间共享的类库。其中两个项目是 Web 角色和辅助角色。

它们都有相同的配置设置:

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

他们每个人都在调用这个函数:

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(DefaultRoleInstanceQueueName);
queue.CreateIfNotExist();
queue.AddMessage(new CloudQueueMessage(Message));
}

当它在辅助角色中执行时,它可以正常工作,没有任何问题;我已确认队列消息的正确读取和写入。当它在 Web 角色中执行时,对queue.CreateifNotExist() 的调用会崩溃,并显示错误“响应在此上下文中不可用”。我已经尝试搜索有关可能导致此问题的原因的信息,但到目前为止我的搜索努力没有结果。如果我可以提供任何其他信息,请告诉我。

最佳答案

好吧,经过大量工作后,我确定这是因为我是从 Global.asax Application_Start 中调用它的。

我将其移至我的 WebRole.cs OnStart() 函数并且它可以正常工作。

关于azure - Windows Azure - Web 角色无法访问本地开发队列存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3639572/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com