I renamed dist/index.js to dist/index.mjs, because Azure Functions apparently can't properly import ESM modules even if type: module is set in package.json unless they have .mjs extension.
Expected behavior
Hello world
Actual behavior
Result: Failure Exception: Worker was unable to load function get: 'A function can only be registered during app startup.' Stack: Error: Worker was unable to load function get: 'A function can only be registered during app startup.' at Object.t.registerFunction (/azure-functions-host/workers/node/dist/src/worker-bundle.js:2:28273) at generic (/home/site/wwwroot/get/node_modules/@azure/functions/dist/azure-functions.js:494:17) at Object.http (/home/site/wwwroot/get/node_modules/@azure/functions/dist/azure-functions.js:428:5) at file:///home/site/wwwroot/get/dist/index.mjs:2:5 at ModuleJob.run (internal/modules/esm/module_job.js:183:25) at async Loader.import (internal/modules/esm/loader.js:178:24)
Known workarounds
Provide a description of any known workarounds.
Related information
Provide any related information
Programming language used: TypeScript
Links to source: n/a
Bindings used: I really don't know - app.http('get', …) thing didn't work, so I guess that would be the config from function.json pasted above?
Investigative information
Please provide the following:
Repro steps
I have created a simple v4 Azure Function:
I then compiled it with TypeScript.
I have added
function.json
with manually defined triggers, because otherwise I got "No HTTP triggers found." error.I renamed dist/index.js to dist/index.mjs, because Azure Functions apparently can't properly import ESM modules even if type: module is set in package.json unless they have .mjs extension.
Expected behavior
Hello world
Actual behavior
Result: Failure Exception: Worker was unable to load function get: 'A function can only be registered during app startup.' Stack: Error: Worker was unable to load function get: 'A function can only be registered during app startup.' at Object.t.registerFunction (/azure-functions-host/workers/node/dist/src/worker-bundle.js:2:28273) at generic (/home/site/wwwroot/get/node_modules/@azure/functions/dist/azure-functions.js:494:17) at Object.http (/home/site/wwwroot/get/node_modules/@azure/functions/dist/azure-functions.js:428:5) at file:///home/site/wwwroot/get/dist/index.mjs:2:5 at ModuleJob.run (internal/modules/esm/module_job.js:183:25) at async Loader.import (internal/modules/esm/loader.js:178:24)
Known workarounds
Provide a description of any known workarounds.
Related information
Provide any related information