Azure Function收到请求后立即加载功能 [英] Load function as soon as Azure Function received the request

查看:52
本文介绍了Azure Function收到请求后立即加载功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

摘要:

我应该在哪里放置加载器,以便azure函数仅为初始请求加载它。

Where should I put the loader, so that azure function only load it for the initial request.

问题:

我在Azure功能中加载了一个加载程序,大约需要1~2分钟,每次加载加载程序都不明智AF收到请求。有没有办法加载初始请求的加载器(旋转AF功能)。

I have a loader to be loaded in Azure function, which takes about 1~2mins and it is not smart to load the loader everytime AF receives a request. Is there a way just load the loader for the initial request(spin the AF function).

当前解决方案:

我将加载器放在main()函数之外,这是有效的。但问题是我不知道为什么在AF功能开始工作之前加载器总是被加载3次。

I put the loader outside the main() functions, which works. But the problem is that I don't know why the loader always being loaded for 3 times before AF function start to work.

推荐答案

我假设"loading""是你正在做的一些对象初始化。

I assume "loader" is some object initialization that you are doing.

处理这样的事情的方法是制作它们是静态的,并在函数调用中重用这些对象 - 基本上是一个Singleton对象。

The way to handle things like this is to make them static and re-use those objects across function calls - basically a Singleton object.

请注意,如果您将比例调整为更多实例,则会为每个实例初始化加载程序。

Note that if you function scales to more instances, the loader is initialized for each instance.


这篇关于Azure Function收到请求后立即加载功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆