Jacek Majer
Jacek Majer

Reputation: 385

Isolated azure function with service bus trigger - connection string from azure app configuration

I have some problems in running the azure function (isolated one) based on .net 6. I would like to get the connection string to the service bus from azure app config. All other settings are succesfuly fetched and served with IOptions pattern: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-6.0 With connection string to service bus, I am getting following error when I am trying to run the function locally:

 Microsoft.Azure.WebJobs.Extensions.ServiceBus: Service Bus account connection string 'AzureServiceBus' does not exist. Make sure that it is a defined App Setting.

The functioln looks like this:

using Api.Contracts.BusMessage;

namespace Api.Functions.Queues;

public class Test
{
    private const string FunctionName = "func";

    private readonly ILogger<Test> _logger;

    public Test(ILogger<Test> logger)
    {
        _logger = logger;
    }

    [Function(FunctionName)]
    public async Task Run(
        [ServiceBusTrigger("func", Connection = "AzureServiceBus")]
        BusMessage<string> message)
    {
        _logger.LogInformation("Processing queue trigger message {@Message}", message);
    }
}

Is it even possible to get connection string from Azure App Configuration?

Upvotes: 3

Views: 4106

Answers (1)

J. Campbell
J. Campbell

Reputation: 730

Service bus connection must come from Function App's own App Settings. It is possible to reference values from Azure App Configuration in the Function App's App settings. See this guide. If you are pulling settings from Azure App Configuration in at runtime of your function, then that will not be usable for the Service Bus connection.

Upvotes: 2

Related Questions