Azure functions: Progamming Model V4
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Describe the feature
Azure relased a new model to programm azure functions.
version
Supports a flexible file structure and code-centric approach to triggers and bindings
This would allow use to give our apps a bigger surface area and also use more advanced features of azure functions
At the moment we are just redirecting everything to a single function with a custom function.json
{
"entryPoint": "handle",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"route": "{*url}",
"methods": ["delete", "get", "head", "options", "patch", "post", "put"]
},
{ "type": "http", "direction": "out", "name": "res" }
]
}
Model V4
The new style would allow us to dynamically define endpoints and handlers in a single(or multiple) main.js that imports from a function folder.
const { app } = require('@azure/functions');
const nitroapp = require('./functions/app')
const fileload= require('./functions/static')
app.http('httpTrigger1', {
methods: ['POST', 'PATCH'],
route:'/api/'
handler: async (req, context) => {
return nitroapp.localCall({
url: req.url,
headers: req.headers,
method: req.method,
body: req.body,
})
}
});
app.http('httpTrigger1', {
methods: ['POST', 'PATCH'],
route:'/static/'
handler: async (req, context) => {
return fileload.localCall({
url: req.url,
headers: req.headers,
method: req.method,
body: req.body,
})
}
});
Pros
- Use the azure infrastuckture better
- better distribute load
- seperate logging
- better cold start due to smaller bundles
- seperate concerns (static content, api,etc)
- allow for more feature down the line
- Queue, timer trigger
- Dynamic middelware
- Fallover endpoints
- Future proofing
Cons
- Feature Gap to other providers
- More work for maintainers
Extra
This could also adress https://github.com/Azure/azure-functions-host/issues/293
In https://github.com/unjs/nitro/blob/8e06f2e4a65c6de0d2f2f3a5ef156ae3821ed60a/src/runtime/entries/azure-functions.ts#L12
Work required
- rewrite src/runtime/entries/azure-functions.ts
- rewrite src/presets/azure-functions.ts
- expose new api (not sure about that, feedback is appreciated)
Additional information
- Would you be willing to help implement this feature?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading src/runtime/entries/azure-functions.ts and src/presets/azure-functions.ts, then compare their current behavior with the linked Azure Functions Model V4 documentation. Clarify the proposed API and implementation scope before changing the files. Done means the project supports the requested Model V4 structure rather than redirecting everything through the current single function.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, typescript
- Domain
- backend, cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100