The following table shows each version of the Node.js programming model along with its supported versions of the Azure Functions runtime and Node.js.
So if you are using Azure Functions 4.x , try to use Node.js 18.x +
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I tried this training to use Azure Blob Storage (and Azure Functions) to store images. Later I want to use it for Azure Cognitive services TTS to save and reuse mp3 speech files: https://learn.microsoft.com/en-us/training/modules/blob-storage-image-upload-static-web-apps/ . But it doesn't seem to work if I follow all the steps. Apparently this is an old training (works with Node.js V3. It asks to use Node.js 12.0 but I see that Node.js versions 10 and 12 aren't supported in Azure Functions 4.x. Are there any examples or training that are more recent using javascript, Azure Functions and Blob Storage?
The following table shows each version of the Node.js programming model along with its supported versions of the Azure Functions runtime and Node.js.
So if you are using Azure Functions 4.x , try to use Node.js 18.x +
Dirk Delbaere Thanks for posting your question in Microsoft Q&A. You are right, training sample is using Node.js V3 and we suggest using newer model V4 for all new developments. We do have a migration guide to convert V3 to V4 Node.Js (which will be helpful) and for more V4 examples/code snippets, check out https://github.com/Azure/azure-functions-nodejs-samples/blob/main/js/src/functions.
Code snippet:
const { app } = require('@azure/functions');
const {
StorageSharedKeyCredential,
ContainerSASPermissions,
generateBlobSASQueryParameters,
} = require("@azure/storage-blob");
const { extractConnectionStringParts } = require('./credentials/utils');
app.http('SASGeneration', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
handler: async (request, context) => {
const permissions = 'c';
const container = 'images';
const sasToken = generateSasToken(process.env.AzureWebJobsStorage, container, permissions);
return { body: `"sasKey":"${sasToken.sasKey}","url":"${sasToken.url}"`};
}
});
function generateSasToken(connectionString, container, permissions) {
const { accountKey, accountName, url } = extractConnectionStringParts(connectionString);
const sharedKeyCredential = new StorageSharedKeyCredential(accountName, accountKey.toString('base64'));
var expiryDate = new Date();
expiryDate.setHours(expiryDate.getHours() + 2);
const sasKey = generateBlobSASQueryParameters({
containerName: container,
permissions: ContainerSASPermissions.parse(permissions),
expiresOn: expiryDate,
}, sharedKeyCredential);
return {
sasKey: sasKey.toString(),
url: url
};
}
I modified the code snippet from the training path for V4 as a reference and please adjust and validate for your actual use case scenarios.
I hope this helps and let me know if any questions.
If you found the answer to your question helpful, please take a moment to mark it as Yes
for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.