Azure函数的集线器启动时是否可以运行代码? [英] Is it possible to run code when a Azure function's Hub is starting?

查看:65
本文介绍了Azure函数的集线器启动时是否可以运行代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Azure Function的集线器启动时运行代码,并确保在该集线器中可以调用任何Azure函数之前执行该代码.我可以这样做吗?

I want to run code when the Azure Function's hub is starting and to be sure that's executed before any Azure function can be called in that hub. Can I do that?

推荐答案

鉴于您正在使用预编译的C#函数,则可以将初始化代码放入静态构造函数中:

Given your are using precompiled C# functions, you could put your initialization code into static constructor:

public static class MyFunctionApp
{
    static MyFunctionApp()
    {
        // Runs once when class is first loaded
    }

    public void Run([SomeTrigger] input)
    {
        // Runs on each event
    }
}

这篇关于Azure函数的集线器启动时是否可以运行代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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