简体   繁体   English

如何处理Azure App Service中长期运行的作业?

[英]How do I handle long running jobs in Azure App Service?

I am rather new to hosting in Azure. 我对于在Azure中托管是相当陌生的。 I have a .net 4.6 Web app, running in Azure as an App Service. 我有一个.net 4.6 Web应用程序,作为应用程序服务在Azure中运行。

The solution contains some actions, that run for a long time. 该解决方案包含一些动作,这些动作会持续很长时间。 These get stopped after a 230 seconds timeout, which seems to be an Azure-thing. 它们在230秒超时后停止,这似乎是Azure事物。

I learned that I should place this code in an Azure Function in order to have it running as a background job. 我了解到,应将此代码放在Azure函数中,以使其作为后台作业运行。 Here there should not be a timeout, as long as I don't use the Consumption plan. 只要我不使用“消费”计划,此处就不应超时。

I also use Azure Storage in my solution. 我还在解决方案中使用Azure存储。

My problem is that if I use Azure Functions v1 (NuGet Microsoft.NET.Sdk.Functions v1.0.24), I am forced to use Newtonsoft.Json version =9.0.1 Meanwhile NuGet WindowsAzure.Storage requires Newtonsoft.Json version >=10.0.2 我的问题是,如果我使用Azure Functions v1(NuGet Microsoft.NET.Sdk.Functions v1.0.24),则不得不使用Newtonsoft.Json版本= 9.0.1,同时NuGet WindowsAzure.Storage需要Newtonsoft.Json版本> = 10.0 0.2

That breaks for me. 这对我来说很糟糕。

Then I tried out Azure Functions v2. 然后,我试用了Azure Functions v2。 But it only supports .Net Core, which is not an option for me in this project. 但是它仅支持.Net Core,这不是我在该项目中的选择。

My main issue is still to find a way to be able to run these long running tasks. 我的主要问题仍然是找到一种方法来运行这些长期运行的任务。

One way could be to break the job into smaller parts, but in this case, I would like to be handle it in the same request. 一种方法是将工作分解成较小的部分,但是在这种情况下,我想在同一请求中处理它。

Check that you do not have a timeout configured in your hosts.json. 检查您的hosts.json中是否没有配置超时。

"functionTimeout": "00:05:00"

The full configuration options for V1 and V2 are documented here . V1和V2的完整配置选项在此处记录

In consumption plan, the maximum timeout is 10 minutes. 在消费计划中,最大超时时间为10分钟。 In an app service plan it can be indefinite (but it makes sense to put a cap in, even if it is just 1 or 2 hours). 在应用服务计划中,它可以是不确定的(但即使只是1或2个小时,也要设定上限)。

If you want to break up your functionality, you may find a suitable Durable Functions pattern . 如果您想破坏功能,可以找到合适的“ 耐用功能”模式

On your Newtonsoft conflict, see if you can address this using a binding redirect . 关于您的Newtonsoft冲突,请查看是否可以使用绑定重定向解决此问题。

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/>
            <bindingRedirect oldVersion="0.0.0.0-9.9.0.0" newVersion="10.0.2.0"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

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

相关问题 如何仅使用5分钟的窥视锁定即可处理发布到服务总线的长期运行的作业 - How to handle long running jobs that are posted to a service bus with only 5min peek lock 具有事务的长期运行作业 Azure 服务总线的模式 - Pattern for long running jobs Azure Service Bus with transactions Azure Web作业的悠久历史影响了应用程序服务计划的性能 - Azure Web Jobs long history affecting app service plan performance 如何在运行 Linux 的 Azure 应用服务上运行 PowerShell 脚本? - How do I run a PowerShell script on an Azure App Service running Linux? 如何从运行在 Azure 的“应用服务”PaaS 上的 IIS 获取 HTTP500 的回溯? - How do I get a traceback of a HTTP500 from IIS running on Azure's "App Service" PaaS? Azure Web 应用程序是 503 服务不可用。 我如何让它恢复运行? - Azure web app is 503 Service Unavailable. How do I get it back running? 用于长时间运行的计划作业的Azure资源类型 - Azure resource types for long running, scheduled jobs 如何处理 Azure 应用服务中的性能问题 - How to handle the performance issue in Azure app service 如何处理 Azure 应用服务 WebSockets 超时? - How to handle Azure App Service WebSockets timeout? 如何让我的 Next.js 应用在运行 ubuntu-latest 的 Azure 应用服务中启动? - How do I get my Next.js app to start in an Azure App Service running ubuntu-latest?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM