I am currently serving images (public access) to users by getting the image urls directly.
const azure = require('azure-storage');
const blobService = azure.createBlobService();
router.route('/image').get( async (req, res, next) => {
try{
let containerName = process.env.CLOUD_PUBLIC_CONTAINER;
let category = req.query.category;
let blobName = category + '/'+ req.query.filename;
let hostName = process.env.AZURE_STORAGE_HOST || 'https://storageaxxxxxx.blob.core.windows.net/';
let url = blobName ? blobService.getUrl(containerName, blobName, null, hostName) : null;
res.json(url)
}catch(e){
console.log(e);
res.status(500).send("Internal Error");
}
})
I am using the https://azure.github.io/azure-storage-node/global.html official nodejs library to communicate with my azure blob storage as you see in the above cloud.
And I know that you can 'cache' your blob storage to a cdn endpoint like this: https://docs.microsoft.com/en-us/azure/cdn/cdn-create-new-endpoint
The thing that I am struggling to find out, how can I serve the cdn image url to client instead of the blob's direct public url? I see nothing in their sdk related to cdn, I imagine something like: " blobService.getNeartestCdnUrl(containerName, blobName, hostName, ...etc)" ?
Note: I just found this old unmaintained package: https://github.com/bestander/deploy-azure-cdn but it's for deployment only it seems and not for serving.