Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.92k stars 441 forks source link

INameResolver doesn't work for durable isolated function (.Net 8) #10270

Open well0549 opened 3 months ago

well0549 commented 3 months ago

Description

I want to be able to get a ServiceBus trigger name with the INameResolver. And have my own implementation

Expected behavior

To resolve the name with the name resolver I implemented.

Actual behavior

Another name resolver is selected, not the one I implemented

Relevant source code snippets

using Microsoft.Azure.WebJobs;

public class CustomNameResolver : INameResolver
{
    public string Resolve(string name)
    {
        // Add logic to resolve the name dynamically.
        return name switch
        {
            "ServiceBusQueue1" => "my-first-servicebus-queue",
            "ServiceBusQueue2" => "my-second-servicebus-queue",
            _ => throw new ArgumentException($"Unknown queue name: {name}")
        };
    }
}

Known workarounds

I can only use environment settings in the current name resolver. But not my own implementation.

App Details

c# image

well0549 commented 2 months ago

It's on isolated consumption plan

cgillum commented 2 months ago

Transferring to a more appropriate repo.

bhagyshricompany commented 2 months ago

Thanks for informing please register service bus properly .

well0549 commented 2 months ago

@bhagyshricompany the servicebus is registered properly, only the nameresolver that I created is not chosen. Instead the DEAFULT name resolver is chosen. If the nameresolver cannot be overwritten for an isolated function, update the documentation. or make the NameResolver overridable so it will work as in non isolated functions

well0549 commented 2 months ago

The code example above is not the actual namersolver but just an example. In the real name resolver i would prepend an environment prefix to the queue.... But this doesn't work whith the current (non overridable) name resolver

well0549 commented 2 months ago

@bhagyshricompany any news? Insights?

jviau commented 2 months ago

@well0549 no API from Microsoft.Azure.WebJobs.* works with dotnet isolated in the function worker. Those packages are not used there, all extensibility points come from Microsoft.Azure.Functions.Worker.*

Can you provide more information about your scenario and need for the INameResolver?

@mattchenderson do we have this documentation somewhere or need to add that?

well0549 commented 2 months ago

I have an environment setting, and i want to prefix the queues wit this environment setting.

It would be much cleaner if I could resolve te queue name dat run time.

I use an environment setting for now, but less settings means less errors