Azure / Azure/azure-functions-host
Custom Function Attributes for function categorization
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 36
Description
#### What problem would the feature you're requesting solve? Please describe.
I want to categorize my function app functions and use that categorization to make decisions in my custom middleware.
#### Describe the solution you'd like
I want to add metadata to my functions via a custom attribute that would be available in the `FunctionDefinition` class via a custom attribute. Something like the following `MyCustomAttribute`:
```
[MyCustomAttribute("Classification1")
[Function("MyTestFunction")]
public IActionResult MyTestFunction([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest request) => new OkObjectResult("Successfully reached API");
```
#### Describe alternatives you've considered
I've tried creating a custom Attribute by inheriting `System.Attribute` and applying the attribute to my function, but I don't see the attribute data included in the FunctionContext.
I've also considered listing all of my functions by name in my middleware and using the existing `FunctionContext.FunctionDefinition.Name` value to determine what action to take based on the name. This is not ideal because it requires me to update the middleware every time I add a new function.
Contributor guide
Assessment
This issue has not been assessed yet.