gpt4 book ai didi

azure - 在控制台中运行 webjob 可以工作,但在 Azure 上抛出异常 : The remote name could not be resolved: 'xxx.queue.core.windows.net'

转载 作者:行者123 更新时间:2023-12-02 07:37:14 25 4
gpt4 key购买 nike

我的网络作业从我的 Blob 存储中删除文档。如果我将代码复制到控制台应用程序并运行它,它将运行完成而不会出现错误。如果我在 Visual Studio 中创建一个新的 WebJob(右键单击我的网站项目并选择“添加”->“新建 Azure WebJob 项目”),将代码复制到 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

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

我没有队列,所以这可能是错误的来源,但奇怪的是我没有尝试访问队列,我只是访问我的 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();
}

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

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();
}
}

编辑:我还应该补充一点,这仅在更新后才开始发生:

  • 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 的方式没有发生任何代码更改。

更新 - 我的网络作业在周末运行完成。它在 22:23 失败,并出现与上面相同的错误,但随后在 22:24 重试时成功运行。但今天又失败了,出现同样的错误。我将尝试删除 @FleminAdambukulam 所说的日志记录,但奇怪的是它在没有任何代码更改的情况下运行,但随后再次失败......

最佳答案

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

关于azure - 在控制台中运行 webjob 可以工作,但在 Azure 上抛出异常 : The remote name could not be resolved: 'xxx.queue.core.windows.net' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39403048/

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