0

I currently have a ServiceBus Trigger in .Net Core 6.0 Isolated. Trying to figure out how to Use Dependency Injection, to set up the Trigger. Trying to figure out how to do this with .Net Core 6.0 Isolated. I have a strongly typed model that is Bound to the appsettings.json file in the Program.cs code. That part works and has been verified. However when trying to do this with .Net Core 6 Isolated It give error about missing reference.

Here's my Config model that is bound to the appsettings.json file. I have left out the appsettings.json file for simplification

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

Here is the Service bus trigger 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. 
        
    }}
4

1 回答 1

0

As of 1-13-2022 it is not possible to do this Using .Net 6 Isolated function. The function does not have access to the Host at this point.

于 2022-01-13T16:03:37.113 回答