0

I am using Azure Function v4 with .NET 8.0 as Isolated Process and want to use multiple output binding as described here.

It looks like this:

public class MultiOutputType
{
    [KafkaOutput("BrokerList",
                 "topic")]
    public string KafkaEvent { get; set; }

    public IActionResult HttpResponse { get; set; }
}

and use this class like this

[Function("test")]
public MultiOutputType Run(
    [HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequest req)
{
    _logger.LogInformation("C# HTTP trigger function processed a request.");

    var kafkaEvent = "some event string";
    var httpResponse = new OkObjectResult("Test successful.");

    return new MultiOutputType
    {
        KafkaEvent = kafkaEvent,
        HttpResponse = httpResponse
    };
}

Now I do not want to hardcode parameters like BrokerList or topic defined in KafkaOutput but want to load these values from configuration like local.settings.json or environment variable.

How can I set these values in the attribute from configuration?

1 Answer 1

0

I figured it out, it can be done by putting %% around the variables, e.g. %BrokerList% and %topic% and define these values in local.settings.json or environment variable.

Hint: When adding these values in local.settings.json, they have to be put unter node "Values". Defining them by their own will not work (at least for me).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.