Search code examples
node.jsangularazureazure-cdn

How to upload files from NodeJS website to Azure CDN?


I need a way to upload images to Azure CDN.

Here's the scenario:

  1. I have an Angular (4.x) web site, it's a client Portal where they can manage their website. They need the ability to upload images that will appear on the website. The images will be stored in the CDN.
  2. The Angular site communicates to a NodeJS WebApi that contains the logic to talk to the database and external services like CDN.
  3. In the Portal, the administrator will add some content and select an image, then click Save. The process should be that the content is saved to the database (which it currently does) and the image will be uploaded to the CDN (which is not currently in place).

I can't find a single bit of instruction on how to do this. The only documentation I've found is how to programmatically manage CDN profiles, etc., but not how to get files into the CDN.

Am I missing something or is this not possible? I know that files get into the CDN somehow, but I haven't found out how.

I've seen some articles that say to upload to Blob Storage and then point the CDN to it. Why is this step necessary? The CDN can store the files, I've seen videos showing this.

Some clarity on this is appreciated.


Solution

  • As such you don't directly store files in CDN in Azure.

    What you do is store the files in Blob Storage and then connect your CDN to Blob Storage (in a manner of speaking) through various means (portal being one).

    Once the files are available in storage, they are automatically replicated to CDN nodes based on how you configure this connection.