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

标签 azure azure-storage azure-web-roles azure-queues

我有一个在我的解决方案中的多个角色项目之间共享的类库。其中两个项目是 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/

相关文章:

Azure 存储浏览客户端软件选项

azure - 无法将域名指向 Windows Azure 网站

c# - 保持 Service Fabric Actor 的状态

azure - 如何续订 Azure API 管理证书

php - Azure使用rest api和php将blob从一个容器复制到同一存储帐户中的另一个容器

vb.net - 即使部署到 Azure,“未在托管服务或 Development Fabric 中运行”

使用 HttpWebRequest 时 Silverlight 5 插件崩溃或请求中止

azure - 如何查找虚拟机是否正在 Azure 中使用托管/非托管磁盘

logging - Web 角色日志记录 - Nlog - 访问配置文件

azure - 如何在没有管理 API 的情况下在 Azure 中查找当前 guest 操作系统版本?