简体   繁体   English

Microsoft.WindowsAzure.Storage.StorageException:远程服务器返回错误:(404)Not Found

[英]Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (404) Not Found

I am receiving this error in my worker role: 我在我的工作角色中收到此错误:

 Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (404) Not Found. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.     at System.Net.HttpWebRequest.GetResponse()     at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](StorageCommandBase`1 cmd, IRetryPolicy policy, OperationContext operationContext)     --- End of inner exception stack trace ---     at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](StorageCommandBase`1 cmd, IRetryPolicy policy, OperationContext operationContext)     at Microsoft.WindowsAzure.Storage.Queue.CloudQueue.DeleteMessage(String messageId, String popReceipt, QueueRequestOptions options, OperationContext operationContext)     at Microsoft.WindowsAzure.Storage.Queue.CloudQueue.DeleteMessage(CloudQueueMessage message, QueueRequestOptions options, OperationContext operationContext)     at CloudCartConnector.TaskRole2.WorkerRole.ExecuteTask() in C:\a\src\CCC\Source\CloudCartConnector.TaskRole2\WorkerRole.cs:line 101  Request Information  RequestID:7a7c08ec-0003-0059-6d7b-2d118f000000  RequestDate:Thu, 03 Dec 2015 03:33:11 GMT  StatusMessage:The specified queue does not exist.  ErrorCode:QueueNotFound  

If there was an exception in the on start method, would this cause a worker role to fail to run? 如果on start方法中存在异常,是否会导致worker角色无法运行? Should I enter a try catch statement in the on start method and just return base.OnStart()? 我应该在on start方法中输入try catch语句并返回base.OnStart()吗? If my storage accounts becomes unavailable, due to a MS upgrade or a server going down, is the try catch the best? 如果我的存储帐户因MS升级或服务器关闭而变得不可用,那么try是最好的吗?

    public override bool OnStart()
    {
        ServicePointManager.DefaultConnectionLimit = 12;
        // Retrieve storage account from connection string.
        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
            CloudConfigurationManager.GetSetting("StorageConnectionString"));

        // Create the queue client.
        CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();

        // Retrieve a reference to a queue.
        queue = queueClient.GetQueueReference("taskqueue");

        return base.OnStart();
    }

Below this code, I execute a task. 在这段代码下面,我执行一个任务。 Should I say if the queue is null, just return? 如果队列为空,我应该说回来吗?

public string GetTasks()
    {


                CloudQueueMessage cloudQueueMessasge = new CloudQueueMessage(message);
                queue.AddMessage(cloudQueueMessasge, new TimeSpan(0, 30, 0));                
        }
        catch (Exception ex)
        {
            return ex.ToString();

        }
    }

You should have a try...catch block in your OnStart method. 您应该在OnStart方法中使用try...catch块。

try{
      CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
      CloudConfigurationManager.GetSetting("StorageConnectionString"));

      // Create the queue client.
      CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();

            // Retrieve a reference to a queue.
       queue = queueClient.GetQueueReference("taskqueue");
}
catch(Microsoft.WindowsAzure.Storage.StorageException e)
{
   // Exception Handling & Logging
   // Return false for OnStart
}

You should also check if queue is null in your GetTasks() method to prevent throwing potential and unnecessary NullReferenceException. 您还应该检查GetTasks()方法中队列是否为null,以防止抛出潜在的和不必要的NullReferenceException。

暂无
暂无

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

相关问题 Azure Worker角色和Blob存储C#-Microsoft.WindowsAzure.Storage.StorageException:远程服务器返回错误:(400)错误的请求 - Azure Worker role and blob storage c# - Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (400) Bad Request Microsoft.WindowsAzure.Storage.StorageException:无法连接到远程服务器 - Microsoft.WindowsAzure.Storage.StorageException: Unable to connect to the remote server Microsoft.WindowsAzure.Storage.dll中出现“Microsoft.WindowsAzure.Storage.StorageException”类型的第一次机会异常 - A first chance exception of type 'Microsoft.WindowsAzure.Storage.StorageException' occurred in Microsoft.WindowsAzure.Storage.dll Microsoft.WindowsAzure.Storage.StorageException 无法加载文件或程序集 'Newtonsoft.Json,版本 = 6.0.0.0, - Microsoft.WindowsAzure.Storage.StorageException Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, 远程服务器返回错误:(404)找不到-HttpWebResponse - The remote server returned an error: (404) Not Found - HttpWebResponse HttpWebRequest引发“ 404远程服务器返回错误:(404)未找到。” - HttpWebRequest throws “The remote server returned an error: (404) Not Found.” for 404 BrowserMob 代理 - 远程服务器返回错误:(404) 未找到 - BrowserMob Proxy - The remote server returned an error: (404) Not Found 远程服务器返回错误:(404)找不到。 在GetResponse()中 - The remote server returned an error: (404) Not Found. In GetResponse() Picasa API返回“远程服务器返回错误:(404)Not Found。” - Picasa API returns “The remote server returned an error: (404) Not Found.” WebDriverManager - '远程服务器返回错误:(404)未找到。' - WebDriverManager - 'The remote server returned an error: (404) Not Found.'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM