I’m looking to create a relatively simple javascript app that runs on node as an azure function app and will eventually return a generated png. I installed the Azure Function extension to get me going with a really simple hello world app. I published this to azure and it works fine.
The issue is – I want to use canvas to create png images but when i modify my code and publish i get No HTTP triggers found and no functions are listed on the azure portal.
I have greatly reduced the code just to show how little code actually breaks it.
httpTrigger1.js
const { app } = require('@azure/functions');
const { createCanvas } = require('canvas'); // ***
app.http('httpTrigger1', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
handler: async (request, context) => {
context.log(`Http function processed request for url "${request.url}"`);
const name = request.query.get('name') || await request.text() || 'world';
const canvas = createCanvas(600, 600); // ***
return { body: `Hello, ${name}!` };
}
});
When removing the lines commented with *** and publish to azure function app the trigger shows and the app returns the body fine.
packages.json
{
"name": "accelerate.ai.chart_v3",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "func start",
"test": "echo "No tests yet...""
},
"dependencies": {
"@azure/functions": "^4.5.1",
"canvas": "^2.11.2"
},
"main": "src/{index.js,functions/*.js}"
}
Azure function app settings:
Stack = Node.js
Node.js Version: Node.js 20 LTS
Using Azure Functions Extension 1.15.4
Thanks