英文:
Dotnet Isolated ServiceBusTrigger connection string setup with Azure App Configuration
问题
I've just switched from dotnet in-process project to an isolated one, but now I have a problem with configuring the connection string in my ServiceBusTrigger.
Program.cs:
var host = new HostBuilder()
    .ConfigureAppConfiguration(builder =>
        builder
            .AddAzureAppConfiguration(options =>
            {
                options.Connect(Environment.GetEnvironmentVariable(CommonConfigurationConstants.AppConfigurationConnectionString))
                    .Select(KeyFilter.Any, LabelFilter.Null)
                    .Select(KeyFilter.Any, ConfigurationConstants.AppLabel)
                    .ConfigureKeyVault(kv =>
                    {
                        kv.SetCredential(new DefaultAzureCredential());
                    })
                    .ConfigureRefresh(refreshOptions =>
                        refreshOptions.Register(CommonConfigurationConstants.SentinelKey, refreshAll: true))
                        .UseFeatureFlags();
            })
            .AddJsonFile("local.settings.json", true))
    .ConfigureFunctionsWorkerDefaults()
    .ConfigureServices(s =>
    {
        s.ConfigureMediatR()
            .ConfigureAutomapper()
            .ConfigureFluentValidations()
            .ConfigureServices()
            .ConfigureRepositories()
            .ConfigureDatabase();
        s.AddFeatureManagement();
    })
    .Build();
host.Run();
SampleFunction.cs:
public class SampleFunction
{
    [Function("SampleFunction")]
    public async Task Run(
        [ServiceBusTrigger(
            "sampleTopic",
            "sampleSubscription",
            Connection = "QueueConnectionString",
            IsSessionsEnabled = true)]
        BaseQueueRequest req, string messageId)
    {
        // ...
    }
}
I added QueueConnectionString to my Azure App Configuration, but still, if I don't place it in local.settings.json, the application does not start. The question is - is there a way to set up this connection string in Azure App Configuration?
英文:
I've just switched from dotnet in proccess project to isolated one, but now I have problem with configuring connection string in my ServiceBusTrigger.
Program.cs
var host = new HostBuilder()
    .ConfigureAppConfiguration(builder =>
        builder
            .AddAzureAppConfiguration(options =>
            {
                options.Connect(Environment.GetEnvironmentVariable(CommonConfigurationConstants.AppConfigurationConnectionString))
                    .Select(KeyFilter.Any, LabelFilter.Null)
                    .Select(KeyFilter.Any, ConfigurationConstants.AppLabel)
                    .ConfigureKeyVault(kv =>
                    {
                        kv.SetCredential(new DefaultAzureCredential());
                    })
                    .ConfigureRefresh(refreshOptions =>
                        refreshOptions.Register(CommonConfigurationConstants.SentinelKey, refreshAll: true))
                        .UseFeatureFlags();
            })
            .AddJsonFile("local.settings.json", true))
    .ConfigureFunctionsWorkerDefaults()
    .ConfigureServices(s =>
    {
        s.ConfigureMediatR()
            .ConfigureAutomapper()
            .ConfigureFluentValidations()
            .ConfigureServices()
            .ConfigureRepositories()
            .ConfigureDatabase();
        s.AddFeatureManagement();
    })
    .Build();
host.Run(); 
SampleFunction.cs
public class SampleFunction
    {
        [Function("SampleFunction")]
        public async Task Run(
            [ServiceBusTrigger(
                "sampleTopic",
                "sampleSubscription",
                Connection = "QueueConnectionString",
                IsSessionsEnabled = true)]
            BaseQueueRequest req, string messageId)
        {
               ...
        }
    } 
I added QueueConnectionString to my Azure App Configuration, but still, if I'll not place it in local.settings.json application does not start.
Question is - is there a way to setup this connection string in Azure App Configuration?
答案1
得分: 0
中间件的表达式解析在独立的Azure Functions中不受支持。这在https://github.com/Azure/AppConfiguration/issues/203中有记录。
英文:
The expression resolution from middleware is not supported in isolated Azure Functions. This is tracked in https://github.com/Azure/AppConfiguration/issues/203.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论