Azure / Azure/azure-functions-host
Function with invalid name gets ignored without an explicit error message
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
#### Investigative information
Issue reproduces locally and in Azure. There's no invocation ID since Azure doesn't see such functions
#### Repro steps
Provide the steps required to reproduce the problem:
1. Create .NET 6 Azure Function project with single function with any trigger and name containing `//` (e.g. `[FunctionName("Example//Name")]`)
2. Start project
#### Expected behavior
After starting the project I should see `'Example//Name' is not a valid function name` error message
#### Actual behavior
Provide a description of the actual behavior observed.
There's no error, the function is quietly skipped and this warning is shown:
> No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

Interestingly sometimes I see the correct error (if I add another function to the same class for example):

But if functions are in different classes, no error is shown:

#### Known workarounds
Guess that your function is skipped because of the invalid name and correct the name 😅
The issue is with investigating the problem (invalid function name), I've spend hours trying to figure out why our Azure Functions are being skipped. Fixing it is easy
#### Related information
Provide any related information
* Programming language used: C#
* Bindings used: None
Source
```csharp
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
namespace TestFunction;
public static class Function1
{
[FunctionName("Example//Name")]
public static void Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
}
}
public static class Function2
{
[FunctionName("Example__Name")]
public static void Run2([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
}
}
```
```xml
net6.0
v4
PreserveNewest
PreserveNewest
Never
```
Contributor guide
Research direction
Start by reproducing the .NET 6 Azure Function project using the FunctionName attribute value "Example//Name", then compare startup behavior when the functions are in the same class versus different classes. Done means an invalid function name produces the expected explicit error while valid functions remain discoverable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100