Particular / NServiceBus.AzureFunctions.InProcess.ServiceBus

Process messages in AzureFunctions using the Azure Service Bus trigger and the NServiceBus message pipeline.
Other
10 stars 5 forks source link

Hosting HttpTrigger and NServiceBusTriggerFunction in same function doesn't recognize serviceBusTrigger #302

Closed JSCProjects closed 2 years ago

JSCProjects commented 3 years ago

I'm hosting HttpTrigger and NServiceBusTriggerFunction inside the same host, but the host doesn't recognize the both functions. So therefore I switched back to the hardcoded variant, but with that I get a warning "Process(Message, ExecutionContext, IMessageReceiver, ILogger)"

"NServiceBus.AzureFunctions.InProcess.ServiceBus" Version="1.3.0"

SeanFeldman commented 3 years ago

@JSCProjects the scenario of hosting various triggers inside the same function app is fully supported. Could you share a repro to demonstrate the Isuzu?

also, the warning seems to be cut off.

SeanFeldman commented 2 years ago

@JSCProjects have you sorted it out? Please close the issue if it's resolved on your end. If not, then more details or a repro would help. Thank you.

JSCProjects commented 2 years ago

I've downloaded this sample and altered EndpointName with one with dots. For example: ASB.Trigger.Queue. And then when I debug I get the following warnings (rider) in image

and

image

SeanFeldman commented 2 years ago

That's because an ASB trigger function name cannot contain periods. Create a non-NSB specific ASB-triggered function and you'll have exactly the same issue:

public static class Function1
{
    [FunctionName("Function1.Test")]
    public static void Run([ServiceBusTrigger("ASB.Trigger.Queue", Connection = "AzureWebJobsServiceBus")]string myQueueItem, ILogger log)
    {
        log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
    }
}

image

You can fix this by overriding the function trigger name:

[assembly: NServiceBusTriggerFunction(endpointName: Startup.EndpointName, TriggerFunctionName = "trigger-function-name")]
JSCProjects commented 2 years ago

Sorry but still no running function with ASB

image

SeanFeldman commented 2 years ago

Mate, share a repro. We can continue playing cat and mouse forever or look at the same code and determine what's wrong and where. Thanks.

JSCProjects commented 2 years ago

Sorry @SeanFeldman here is a [service-bus_asbfunctions_jsc.zip](https://github.com/Particular/NServiceBus.AzureFunctions.InProcess.ServiceBus/files/7425015/service-bus_asbfunctions_jsc.zip

SeanFeldman commented 2 years ago

The zip file is the sample project straight from the sample, just with custom queue and trigger function names 🙂 I'm sorry, but it just works...

image image image image

There's something either off with the environment where you develop or your computer is sending a clear signal it's ready to retire and you should let it go, @JSCProjects.

JSCProjects commented 2 years ago

Hmm strange! I receive the following warning when I build the solution on this computer.

CSC : warning CS8032: An instance of analyzer NServiceBus.AzureFunctions.SourceGenerator.TriggerFunctionGenerator2 cannot be created from C:\Users\JoeyChömpff\.nuget\packages\nservicebus.azurefunctions.inprocess.servicebus\2.0.2\analyzers\dotnet\cs\NServiceBus.AzureFunctions.SourceGenerator.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=3.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified..

So I tried it with another computer and then it works.

SeanFeldman commented 2 years ago

There's something either off with the environment where you develop or your computer

That's not the code. The issue can be closed 🙂