Azure / azure-functions-vs-build-sdk

MSBuild task for Azure Functions
MIT License
96 stars 62 forks source link

Generator doesn't warn when [FunctionName] is specified on a private function #619

Open AtOMiCNebula opened 10 months ago

AtOMiCNebula commented 10 months ago

The Generator will happily generate a functions.json for code that the host can't handle. Specifically, code like this:

public class ExampleFunctions
{
    [FunctionName("Foo")]
    private void Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req)
    {
        // ...
    }
}

The Functions Host doesn't actually load the function because it's private (and reports a single trace log about it in App Insights, oy). Either the Generator should throw a warning/error in this case, or the host should enumerate private methods. Just need both parts to be consistent with each other. 😄

bhagyshricompany commented 9 months ago

Thanks for reporting will discuss and update.

bhagyshricompany commented 9 months ago

The error message suggests that the Azure Functions host doesn't load the function because it's marked as private.is there you specifically use private method otherwise if you create public method then this error will not face.

AtOMiCNebula commented 9 months ago

@bhagyshricompany / @fabiocav, yes I'm aware. The problem I'm trying to highlight is that this should be something the Generator reports as an error at compile-time, not as a warning/trace at run-time. The generator should not generate a host.json that it knows the host won't actually be able to process.

I've reported a similar issue where the Generator generates doomed-to-fail host.json when there are multiple overloads of a function in #583.