在Azure函数中使用IoC容器 [英] using IoC container in azure functions

查看:81
本文介绍了在Azure函数中使用IoC容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我习惯于使用 TopShelf 编写Windows服务来完成所有在Windows中无法完成的工作Web请求,并逐渐转向使用Azure功能.

I have been used to writing Windows Services using TopShelf to do all stuff which cannot be done in a web request and am slowly moving to using azure functions.

有了topshelf,我通常可以做到

With topshelf I could generally do

  1. 在服务启动时扫描并注册
  2. 为每个票证/请求使用嵌套容器

如何在天蓝色函数调用中使用IOC?我应该完全使用它吗?

How can I use IOC in an azure function call ? Should I be using it at all ?

推荐答案

在Azure Functions中,目前还没有一种以自然方式进行IOC的方法.通常,您希望在应用程序启动时初始化IOC容器,但是我们目前不提供执行此操作的方法.我们的回购中有一个与该问题有关的未解决问题,此处 .此外,我们必须使该容器可用于Function实例.

No there isn't currently a way to do IOC in a natural way in Azure Functions. Generally you'd want to initialize your IOC container at application startup, but we don't currently give you a way to do that. We have an open issue in our repo related to that here. Furthermore, we'd have to make this container available to Function instances.

这篇关于在Azure函数中使用IoC容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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