azure - Azure Web作业功能状态为“永不结束”

标签 azure azure-webjobs azure-webjobssdk

我已经创建了天蓝色的网络工作。 Web作业是连续运行的一种类型。当队列中有消息时将调用Web作业功能。我可以通过Azure存储资源管理器或mvc Web应用程序在队列中添加消息来调用Web作业功能。

Web作业是一个控制台应用程序,它需要大约一个小时的时间才能通过本地运行命令行来执行工作。调用Web作业成功启动后,但经过一段时间(大约5到10分钟),我在Web作业日志中发现功能调用状态为“未完成”。

所以我的问题如下:

1)是由于长期运行任务导致的此问题吗?

2)是否由于处理过程中的任何错误而导致此问题。(但是我可以在本地运行)

3)如果我从Web作业添加的数据库中删除记录,则发现该Web再次启动。为什么?

4)完成流程后是否需要从队列中删除消息?

这是我从Web作业中调用的代码片段

namespace Scheduler
{
class Program
{
    static void Main()
    {

        JobHost host = new JobHost();
        host.RunAndBlock();
    }

    public static void ProcessQueueMessage([QueueTrigger("webjobschedularargs")] string schedularargs,
                                  [Blob("containername/blobname")]TextWriter writer)
    {
        //writer.WriteLine(inputText);
        string[] args = schedularargs.Split(new char[0]);

        RunProcess(args);
        writer.WriteLine(schedularargs);
    }

    private static void RunProcess(string[] args)
    {
        if (!Initialize())
        {
            // Log issue
            Console.WriteLine("Error!!! Unable to initialize.");
            Console.ReadKey(true);

            // We're done
            return;
        }

        #region Run processor

        var options = new Options();
        var timer = new Stopwatch();

        if (CommandLine.Parser.Default.ParseArguments(args, options))
        {
            Console.WriteLine("Processing: ");
            timer.Start();

            if (options.Profiles != null)
            {
                foreach (var profile in options.Profiles)
                {
                    Console.Write(profile + ", ");
                }
                Console.WriteLine();
            }

            if (options.Reports != null)
            {
                foreach (var report in options.Reports)
                {
                    Console.Write(report + ", ");
                }
                Console.WriteLine();
            }

            var processor = new Processor(options);
            processor.Start();
        }

        #endregion
        // Log reason why not valid command args

        //-----call run processor function

        timer.Stop();
        Console.WriteLine("Total time (ms): " + timer.ElapsedMilliseconds);
        Console.WriteLine("Done!!! Everything went ok.");

        //#if LOCAL
        //            Console.ReadKey(true);
        //#endif
    }



    private static bool Initialize()
    {
        // Set ninject values
        NinjectConfig.Start();

        // TODO: Set automapper values ??

        return true;
    }
}

}

编辑:-

我遇到了天蓝色的跟踪错误。

[07/10/2014 15:50:52> 32a9e0:ERR]未处理的异常:
Microsoft.WindowsAzure.Storage.StorageException:远程服务器返回错误:(404)找不到。 ---> System.Net.WebException:远程服务器返回错误:(404)找不到。

[07/10/2014 15:50:52> 32a9e0:ERR]在System.Net.HttpWebRequest.GetResponse()

[07/10/2014 15:50:52> 32a9e0:ERR]在
Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync [T](RESTCommand`1 cmd,IRetryPolicy策略,OperationContext operationContext)

[07/10/2014 15:50:52> 32a9e0:ERR] ---内部异常堆栈跟踪的结尾---

[07/10/2014 15:50:52> 32a9e0:ERR]在
Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync [T](RESTCommand`1 cmd,IRetryPolicy策略,OperationContext operationContext)

[07/10/2014 15:50:52> 32a9e0:ERR]在
Microsoft.WindowsAzure.Storage.Queue.CloudQueue.UpdateMessage(CloudQueueMessage消息,TimeSpan可见性超时,MessageUpdateFields updateFields,QueueRequestOptions选项,OperationContext operationContext)

[07/10/2014 15:50:52> 32a9e0:ERR]在Microsoft.Azure.Jobs.UpdateQueueMessageVisibilityCommand.TryExecute()

[07/10/2014 15:50:52> 32a9e0:ERR]在Microsoft.Azure.Jobs.LinearSpeedupTimerCommand.Execute()

[07/10/2014 15:50:52> 32a9e0:ERR]在Microsoft.Azure.Jobs.IntervalSeparationTimer.RunTimer(对象状态)

[07/10/2014 15:50:52> 32a9e0:ERR]在System.Threading.TimerQueueTimer.CallCallbackInContext(对象状态)

[07/10/2014 15:50:52> 32a9e0:ERR]在
System.Threading.ExecutionContext.RunInternal(ExecutionContext executeContext,ContextCallback回调,对象状态,布尔类型saveSyncCtx)

[07/10/2014 15:50:52> 32a9e0:ERR]在
System.Threading.ExecutionContext.Run(ExecutionContext executeContext,ContextCallback回调,对象状态,布尔类型saveSyncCtx)

[07/10/2014 15:50:52> 32a9e0:ERR]在System.Threading.TimerQueueTimer.CallCallback()

[07/10/2014 15:50:52> 32a9e0:ERR]在System.Threading.TimerQueueTimer.Fire()

[07/10/2014 15:50:52> 32a9e0:ERR]在System.Threading.TimerQueue.FireNextTimers()

[07/10/2014 15:50:52> 32a9e0:ERR]在
System.Threading.TimerQueue.AppDomainTimerCallback()

[07/10/2014 15:50:52> 32a9e0:INFO] ................................. ................................................... ................................................... ......
[07/10/2014 15:50:52> 32a9e0:SYS ERR]由于退出代码-532462766,作业失败

[07/10/2014 15:50:52> 32a9e0:SYS INFO]进程关闭,等待0秒

[07/10/2014 15:50:52> 32a9e0:SYS INFO]状态已更改为PendingRestart

[07/10/2014 15:50:57> 32a9e0:SYS INFO]使用脚本主机-“WindowsScriptHost”运行脚本“Scheduler.exe”

[07/10/2014 15:50:57> 32a9e0:SYS INFO]状态已更改为“正在运行”

因此,查看错误我尝试从本地控制台应用程序及其工作中执行相同的功能。多次运行后,我发现该功能正执行5分钟,因此是否有时间在Web作业中运行任何功能。

谢谢。

最佳答案

WebJobs sdk中似乎有一个错误,即它没有创建应该默认创建的blob容器,具体取决于创建存储帐户的时间和地点。我要做的是自己创建容器。

他们是:

天蓝色工作主机输出
天蓝色webjobs主机

那为我解决了问题。

关于azure - Azure Web作业功能状态为“永不结束”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24658560/

相关文章:

azure - 在 Azure Monitor 中查看 opentelemetry 跟踪

azure - 如何将 SSL 证书附加到 Azure 容器实例

jenkins - msbuild 与命令行与 Jenkins 的行为不同

azure - 连续的 Azure Web 作业在交换到新插槽后是否会重新启动?

dependency-injection - 静态函数范围内 DbContext 的依赖注入(inject) Ninject 与 WebJobs

azure - Azure WebJob Sdk beta 0.5 中的 ServiceBusTrigger 批处理

azure - Linux 机器上的 rm -rf 速度慢

Windows Azure : Creating a subdirectories inside the blob

azure - 如何在 AzureFunction V2 上的 ServiceBus BrokeredMessage 级别放弃消息或死信消息?

azure - 为什么 HttpClient PostAsJsonAsync 退出 Azure Web 作业而不运行其后的代码?