-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(azure-functions): support Azure Functions programming model v4 (#…
…4426) See https://learn.microsoft.com/en-ca/azure/azure-functions/functions-node-upgrade-v4 This builds on the work in #4178 by @qzxlkj, which provide most of the runtime code fix. The rest of this is adding testing and updated examples and docs. Refs: #4178 Closes: #3185
- Loading branch information
Showing
64 changed files
with
1,162 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
APP_NAME=$(USER)-example-azure-function-app | ||
|
||
.PHONY: print-app-name | ||
print-app-name: | ||
@echo "APP_NAME: $(APP_NAME)" | ||
|
||
.PHONY: publish | ||
publish: | ||
func azure functionapp publish "$(APP_NAME)" | ||
|
||
# Note that the Azure Functions log stream is extremely flaky. Don't expect it | ||
# to reliably be able to show logs from the deployed function app. | ||
.PHONY: logstream | ||
logstream: | ||
func azure functionapp logstream "$(APP_NAME)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": "2.0", | ||
"logging": { | ||
"applicationInsights": { | ||
"samplingSettings": { | ||
"isEnabled": true, | ||
"excludedTypes": "Request" | ||
} | ||
} | ||
}, | ||
"extensionBundle": { | ||
"id": "Microsoft.Azure.Functions.ExtensionBundle", | ||
"version": "[4.*, 5.0.0)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require('elastic-apm-node').start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "example-azure-function-app", | ||
"version": "2.0.0", | ||
"description": "An example Azure Function app showing Elastic APM integration for tracing/monitoring", | ||
"private": true, | ||
"main": "{initapm.js,src/functions/*.js}", | ||
"engines": { | ||
"node": ">=20" | ||
}, | ||
"scripts": { | ||
"start": "func start", | ||
"dev:sync-local-apm-agent-changes": "rsync -av ../../lib/ ./node_modules/elastic-apm-node/lib/" | ||
}, | ||
"dependencies": { | ||
"@azure/functions": "^4.0.0", | ||
"elastic-apm-node": "^4.11.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const { app } = require('@azure/functions'); | ||
|
||
app.http('Hello', { | ||
methods: ['GET'], | ||
authLevel: 'anonymous', | ||
handler: async (_request, _context) => { | ||
const url = new URL('http://worldtimeapi.org/api/timezone/America/Vancouver'); | ||
const timeRes = await fetch(url, { signal: AbortSignal.timeout(5000) }); | ||
const timeBody = await timeRes.json(); | ||
|
||
const body = JSON.stringify({ | ||
hello: 'world', | ||
'current time in Vancouver': timeBody.datetime | ||
}); | ||
return { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Content-Length': Buffer.byteLength(body) | ||
}, | ||
body | ||
}; | ||
}, | ||
}); |
Oops, something went wrong.