运行在控制台作品webjob而是抛出异常在Azure上:远程名称不能被解析:xxx.queue.core.windows.net"

gar*_*thb 1 azure azure-storage azure-storage-blobs azure-web-sites

我的webjob从我的blob存储中删除文档.如果我将代码复制到控制台应用程序并运行它,它将运行完成而不会出现错误.如果我在visual studio中创建一个新的webjob(右键单击我的网站项目并选择Add - > New Azure Webjob project),将代码复制到Functions.cs并进行部署,Azure在运行webjob时抛出异常:

===============================================

[09/09/2016 01:51:44 > fc93a9: ERR ] Unhandled Exception: Microsoft.WindowsAzure.Storage.StorageException: The remote name could not be resolved: 'xxx.queue.core.windows.net' ---> System.Net.WebException: The remote name could not be resolved: 'xxx.queue.core.windows.net'
[09/09/2016 01:51:44 > fc93a9: ERR ]    at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
[09/09/2016 01:51:44 > fc93a9: ERR ]    at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult)
[09/09/2016 01:51:44 > fc93a9: ERR ]    --- End of inner exception stack trace ---
[09/09/2016 01:51:44 > fc93a9: ERR ]    at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result)
[09/09/2016 01:51:44 > fc93a9: ERR ]    at Microsoft.WindowsAzure.Storage.Queue.CloudQueue.EndExists(IAsyncResult asyncResult)
[09/09/2016 01:51:44 > fc93a9: ERR ]    at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass1`1.<CreateCallback>b__0(IAsyncResult ar)
[09/09/2016 01:51:44 > fc93a9: ERR ] --- End of stack trace from previous location where exception was thrown ---
[09/09/2016 01:51:44 > fc93a9: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[09/09/2016 01:51:44 > fc93a9: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[09/09/2016 01:51:44 > fc93a9: ERR ]    at Microsoft.Azure.WebJobs.Host.Queues.Listeners.QueueListener.<ExecuteAsync>d__4.MoveNext()
[09/09/2016 01:51:44 > fc93a9: ERR ] --- End of stack trace from previous location where exception was thrown ---
[09/09/2016 01:51:44 > fc93a9: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[09/09/2016 01:51:44 > fc93a9: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[09/09/2016 01:51:44 > fc93a9: ERR ]    at Microsoft.Azure.WebJobs.Host.Timers.TaskSeriesTimer.<RunAsync>d__d.MoveNext()
[09/09/2016 01:51:44 > fc93a9: ERR ] --- End of stack trace from previous location where exception was thrown ---
[09/09/2016 01:51:44 > fc93a9: ERR ]    at Microsoft.Azure.WebJobs.Host.Timers.BackgroundExceptionDispatcher.<>c__DisplayClass1.<Throw>b__0()
[09/09/2016 01:51:44 > fc93a9: ERR ]    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
[09/09/2016 01:51:44 > fc93a9: ERR ]    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
[09/09/2016 01:51:44 > fc93a9: ERR ]    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
[09/09/2016 01:51:44 > fc93a9: ERR ]    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
[09/09/2016 01:51:44 > fc93a9: ERR ]    at System.Threading.ThreadHelper.ThreadStart()
[09/09/2016 01:51:44 > fc93a9: SYS ERR ] Job failed due to exit code -532462766

=======================================================
Run Code Online (Sandbox Code Playgroud)

我没有队列,所以这可能是错误来自哪里,但奇怪的是我不尝试访问队列,我只访问我的blob存储.

不确定这是否有帮助,但我的webjobs Program.cs看起来像这样:

    static void Main()
    {
        JobHostConfiguration config = new JobHostConfiguration();
        config.Tracing.ConsoleLevel = TraceLevel.Verbose;

        config.UseTimers();

        var host = new JobHost(config);
        // The following code ensures that the WebJob will be running continuously
        host.RunAndBlock();
    }
Run Code Online (Sandbox Code Playgroud)

这是作业中唯一使用存储的代码,其余的是获取列表的数据库内容等.

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

// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("agentdocuments");

foreach (var doc in expiredDocs)
{
    if (doc.ContentLength == 1)
    {
        // Retrieve reference to blob
        CloudBlockBlob blockBlob = container.GetBlockBlobReference($"{doc.SubDomain.ToLower()}/{doc.ClientId}/{doc.FileId}");

        await blockBlob.DeleteIfExistsAsync();
    }
}
Run Code Online (Sandbox Code Playgroud)

编辑:我还应该补充说,这只是在更新后才开始:

  • Microsoft.Azure.WebJobs从1.1.1到1.1.2
  • Microsoft.Azure.WebJobs.Core从1.1.1到1.1.2
  • WindowsAzure.Storage从5.0.2到7.2.0和

还有一些代码更改和其他更新(如Newtonsoft.Json,Microsoft.WindowsAzure.ConfigurationManager,Microsoft.Web.WebJobs.Publish)但没有代码更改我访问blob的方式.

更新 - 我的webjob周末跑完了.它在22:23失败并出现与上述相同的错误,但在22:24重试时成功运行.但是今天再次以同样的错误再次失败.我要去尝试删除该记录由@FleminAdambukulam但奇怪的说,它如何运行,没有任何代码更改,但随后再次失败......

Dav*_*bbo 6

问题是存储帐户是仅支持Blob的特殊类型.即使您没有使用队列,WebJobs SDK也会在内部依赖它们.因此,要使用WebJobs SDK,您需要使用常规存储帐户.

  • FRACKIN FRACK!请原谅我的战斗人员....但是生活在神秘之地上面的天堂之神,被称为'云',有一些神奇的力量,他们可以借给我轻松地将我的blob复制到我将创建的新存储中不要让我的网站停止上传新文件.我愿意牺牲3只山羊和1只羊羔!我知道你只是他们的仆人@DavidEbbo,但我求求你,代表我们与他们交谈! (3认同)