如何在一个Azure Function应用程序中为所有功能使用一个依赖容器? [英] How to use one Dependency Container for all of functions in one Azure Function app?

查看:86
本文介绍了如何在一个Azure Function应用程序中为所有功能使用一个依赖容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用' 针对我的功能应用程序的基于Autofac的依赖项注入实现 ".

我注释 DependencyInjectionConfig ( typeof ( DIConfig ))] 我的azure函数应用中的所有azure函数.轻抚这个nuget软件包后 源代码 ,我意识到每个函数都有其自己的容器,而我的函数应用实际上具有"Dictionary< string,IContainer>".容器".

如何在我的函数应用程序中仅对所有函数使用一个容器?<​​/p>

谢谢.

解决方案

对于Azure中的函数,可以将它们添加到Function App.这意味着该应用程序中的所有功能将共享相同的资源.这就是为什么您为每个功能应用程序选择特定的应用程序服务计划或消费计划,并将其应用于所有功能的原因 在该功能应用程序中.

您的Function App中的每个功能都被认为是彼此独立的.当然,您可以从功能应用程序"页面中管理一些全局设置,例如应用程序版本和Vnet集成.但是您也会注意到,您可以管理每个功能 分别在功能应用内.

这么长的答案很简短,您的每个函数都将在其自己的容器中运行,并且无法合并到同一个容器中. 


Hi, 

I am using 'An Autofac based implementation of Dependency Injection' for my function app. 

I annotate [DependencyInjectionConfig(typeof(DIConfig))] to all azure functions in my azure function app. Afer cheking this nuget package source code,  I realized each function has its own container, and my function app in fact has 'Dictionary<string, IContainer> containers'. 

How can I use only one container for all of my functions in my function app? 

Thanks.

解决方案

For Functions in Azure you can add them to a Function App. This means that all functions in that app will share the same resources. This is why you select a specific app service plan or consumption plan per Function App and it applies to all the functions in that Function App. 

Each function in your Function App are considered independent of eachother. There are course a few global settings you can manage from the Function App page such as app version and Vnet integration. But as you will also notice you can manage each function individually inside the function app. 

So long answer short, each of your functions will run in it's own container and cannot be combined into the same one. 


这篇关于如何在一个Azure Function应用程序中为所有功能使用一个依赖容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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