如何使用 .Net Core 6.0 Isolated 设置具有依赖注入的 ServiceBusTrigger

How to set up ServiceBusTrigger with Dependency Injection with .Net Core 6.0 Isolated

我目前在 .Net Core 6.0 Isolated 中有一个 ServiceBus 触发器。试图弄清楚如何使用依赖注入来设置触发器。试图弄清楚如何使用 .Net Core 6.0 Isolated 来做到这一点。 我有一个强类型模型,它绑定到 Program.cs 代码中的 appsettings.json 文件。该部分有效并且已经过验证。但是,当尝试使用 .Net Core 6 Isolated 执行此操作时,它会给出有关缺少引用的错误。

这是我绑定到 appsettings.json 文件的配置模型。为了简化起见,我省略了 appsettings.json 文件

    public  class MyConfig
{
    public string Topic { get; set; }
    public string SubscriptionName { get; set; }
}

这是服务总线触发器class

public class ServiceBusTriggerClass
{
  
    private readonly MyConfig _myConfig;

    public ServiceBusTriggerClass(IOptions<MyConfig> config)
    {
        _myConfig= config.Value;
    }

 
    [Function("MySBFunction")]
    public async Task MySBFunction([ServiceBusTrigger(_myConfig.Topic, _myConfig.SubscriptionName)] object myObject)
    {
 // Do things with the myObject thing. 
        
    }}

从 1-13-2022 开始,无法使用 .Net 6 隔离功能执行此操作。该函数此时无权访问主机。