简体   繁体   English

Windows Azure队列 - CloudQueue.GetMessage()不适用于最新版本的Microsoft.WindowsAzure.Storage(v5.0.0)

[英]Windows Azure Queue - CloudQueue.GetMessage() not working for latest version of Microsoft.WindowsAzure.Storage (v5.0.0)

I'm new to Azure and trying out the tutorial here . 我是Azure的新手, 在这里尝试教程。

The tutorial is about creating a Cloud Service on Azure taking advantage of the Web Role delegating task to the Worker Role. 本教程是关于在Azure上创建Cloud Service,利用Web角色委派任务到Worker Role。 The only part that matters; 唯一重要的部分; when user uploads an image to the Web Role, the Web Role will put the image in Azure Storage and create a new record in the database with a field containing the URL of the stored image. 当用户将图像上载到Web角色时,Web角色会将图像放入Azure存储中,并使用包含存储图像的URL的字段在数据库中创建新记录。 The Web Role next places a message (the ID of the newly added record) in Azure Queue. Web角色接下来在Azure队列中放置一条消息(新添加的记录的ID)。

var queueMessage = new CloudQueueMessage(id);
await _cloudQueue.AddMessageAsync(queueMessage);

The Worker Role will then retrieve the message from the queue. 然后,Worker Role将从队列中检索消息。 Next, retrieve the record from the database. 接下来,从数据库中检索记录。 Then create a thumbnail from the image url of the retrieved database record. 然后从检索到的数据库记录的图像URL创建缩略图。

while (true) {
    var msg = _cloudQueue.GetMessage();
    if (msg != null) {
        CreateThumbnail();
    }

    System.Threading.Thread.Sleep(1000);
}

The tutorial offers guidance to 本教程提供了指导

  1. download the solution source files and open from Visual Studio 下载解决方案源文件并从Visual Studio打开
  2. or create the solution from scratch using Visual Studio 或使用Visual Studio从头开始创建解决方案

The solution works fine when using the downloaded source files. 使用下载的源文件时,该解决方案工作正常。 In the Worker Role, var msg = _cloudQueue.GetMessage(); 在Worker Role中, var msg = _cloudQueue.GetMessage(); .

msg always has something (not null) albeit there's a delay of 3 to 4 seconds after the image is uploaded. msg总是有东西(不是null),虽然上传图像后会有3到4秒的延迟。 Therefore CreateThumbnail() is always executed 3 to 4 seconds after the image is uploaded. 因此,在上传图像后3到4秒始终执行CreateThumbnail()

However, if I were to create the solution from scratch, msg is always null no matter how long I waited and CreateThumbnail was never executed. 但是,如果我从头开始创建解决方案,无论我等待多长时间并且从未执行过CreateThumbnailmsg始终为null。 I made sure the Worker Role was indeed running by putting breakpoint here and there. 我通过在这里和那里放置断点来确保工作者角色确实在运行。

The source of the problem 问题的根源

After a few painstaking hours, I have boiled the problem down to the assembly Microsoft.WindowsAzure.Storage . 经过几个艰苦的工作,我把问题归结为程序集Microsoft.WindowsAzure.Storage The solution source files downloaded from the tutorial page is using version 3.2.0 while the solution created from scratch is using the latest version 5.0.0 from NuGet. 从教程页面下载的解决方案源文件使用的是3.2.0版本,而从头开始创建的解决方案使用的是NuGet的最新版本5.0.0。 So in order words, msg is always null if I'm using the latest version 5.0.0 of Microsoft.WindowsAzure.Storage on the Worker Role. 所以按顺序说,如果我在Worker Role上使用最新的5.0.0版本的Microsoft.WindowsAzure.Storagemsg总是为null。 Is this a known issue or am I missing something. 这是一个已知问题还是我遗漏了一些东西。

I'm sorry you've had difficulty getting this tutorial to work. 对不起,你很难让这个教程发挥作用。 I've checked with the owner of the tutorial, and it's been recently updated (around 9/1). 我已经与教程的所有者核实了,并且最近更新了(大约9/1)。 Please download the new version of the Visual Studio solution and try it again. 请下载新版本的Visual Studio解决方案并再次尝试。

There are a few things to keep in mind, which are outlined in the troubleshooting section of the tutorial: 有几点需要注意,本教程的故障排除部分对此进行了概述:

  • Change the startup project to ContosoAdsCloudService 将启动项目更改为ContosoAdsCloudService
  • Run Visual Studio as an administrator, and specify that the solution should run with the full compute emulator instead of the express emulator. 以管理员身份运行Visual Studio,并指定解决方案应使用完整计算模拟器而不是快速模拟器运行。

From the tutorial: 从教程:

By default new cloud service projects use the Azure compute emulator express to simulate the Azure environment. 默认情况下,新的云服务项目使用Azure计算模拟器来模拟Azure环境。 This is a lightweight version of the full compute emulator, and under some conditions the full emulator will work when the express version does not. 这是完整计算模拟器的轻量级版本,在某些情况下,当快速版本没有时,完整模拟器将起作用。

To change the project to use the full emulator, right-click the ContosoAdsCloudService project, and then click Properties. 若要更改项目以使用完整模拟器,请右键单击ContosoAdsCloudService项目,然后单击“属性”。 In the Properties window click the Web tab, and then click the Use Full Emulator radio button. 在“属性”窗口中,单击“Web”选项卡,然后单击“使用完全模拟器”单选按钮。

In order to run the application with the full emulator, you have to open Visual Studio with administrator privileges. 要使用完整模拟器运行应用程序,必须使用管理员权限打开Visual Studio。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 VS 2013 Windows Azure中有关程序集Microsoft.WindowsAzure.Storage.Emulator.Controller的运行时错误 - Runtime error in VS 2013 Windows Azure regarding an assembly Microsoft.WindowsAzure.Storage.Emulator.Controller 无法发布到Azure-Microsoft.WindowsAzure.Storage.CloudStorageAccount ctor不匹配 - Cannot publish to Azure - Microsoft.WindowsAzure.Storage.CloudStorageAccount ctor doesn't match 命名空间“Microsoft.WindowsAzure”中不存在类型或命名空间名称“Storage” - The type or namespace name 'Storage' does not exist in the namespace 'Microsoft.WindowsAzure' 如何解决Windows Azure诊断运行时错误(无法创建WindowsAzure.Diagnostics,版本= xx,Culture = neutral,PublicKeyToken = xx - How to solve Windows Azure Diagnostic Runtime Error (Could not create WindowsAzure.Diagnostics, Version=xx, Culture=neutral, PublicKeyToken=xx 初始化Microsoft Azure存储模拟器SDK2.8失败 - Failed to initialize Microsoft Azure storage emulator SDK2.8 无法在我的项目中安装Nuget软件包WindowsAzure.Storage - Not able to install Nuget Package WindowsAzure.Storage in my project 将Microsoft.WindowsAzure.StorageClient添加到Visual Studio 2013 - Adding Microsoft.WindowsAzure.StorageClient to Visual Studio 2013 如何在Visual Studio 2013中安装WindowsAzure.Storage? - How do I install WindowsAzure.Storage in Visual Studio 2013? 如何将最新版本的 Microsoft Build Tools 2013 安装到我的构建服务器上? - How can I get the latest version of Microsoft Build Tools 2013 onto my build server? 编码的用户界面不适用于最新的Chrome浏览器版本54 - Coded UI not working for latest Chrome browser version 54
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM