Azure / Azure/azure-functions-host

Do not require attributes in .NET functions

Open
#4,234 25 comments 45 reactions 0 assignees View on GitHub
enhancement needs-discussion
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 10h
Merged PRs (30d)
36

Description

This is a suggestion, not a bug, so I'm ignoring the template.

Discussed with @mattchenderson, now documenting here.

## No attributes

It used to be that the attributes in .NET functions were optional: one could define `function.json` file and this would get the functions started. This doesn't seem to work anymore: last time I tried to create Activity functions with just json files without attributes, but the functions aren't discovered by the runtime. The [docs](https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library) say that I can't edit `function.json` manually, so I assume this is by design.

## Avoiding many similar functions

I came to this need because I find myself defining many functions very similar to each other, having the same binding types but requiring different values in the bindings, e.g.

- Queue processors that are one-liners calling into my domain code. The only difference is the queue name
- Activities that are one-liners calling into [F# computation expressions](https://github.com/mikhailshilkov/DurableFunctions.FSharp/blob/master/samples/FanOutFanIn.fs#L23-L24) that are only different by activity name and parameter type

So, instead of copying the functions over and over again, I'd love to automate this process.

## DSLs

I guess a better meta-description is that I'm trying to use my own DSLs that compile into functions. Examples:

- F# DSL for durable functions
- Event-sourcing based system where I define command handlers, event handlers, projections, and then I want to run all that on top of functions
- Streaming pipelines (queues or hubs sending to queues or hubs)

Now, I have to define DSLs *and* dumb functions calling into it.

## Factory

Functions used to be static methods in static classes. Now they can be instances. The next step could be creating factory methods: define an `Init` method or something in `Startup` configuration to run a factory method which returns `List`, where `Function` defines what's now in `function.json`.

I see some complications with that, especially if factories are not deterministic. So, instead of runtime, the factory method could be invoked at compile time, it could even be the source for auto-generated `function.json` files.

## Extensibility

I'm looking for the world where 3rd party libraries could compile themselves into function apps. In addition to my examples above, the [Function Monkey](https://functionmonkey.azurefromthetrenches.com/) framework kind of does that today, but it has to do some nasty templating and compile-time roslyn acrobatics to achieve that. I could see things like ASP.NET Core or [Saturn](https://github.com/SaturnFramework/Saturn) compile themselves into functions.

Contributor guide

Open the contributing guide

Research direction

No repository file, test, or entry point is named. Start by reviewing the host's .NET function discovery behavior around attributes and function.json, then clarify whether the desired outcome is attribute-free discovery, factory-generated functions, or compile-time generation; completion criteria are not defined in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.