Where to place code for authentication and file actions for NodeJS API?
Hi, I want users to be able to upload/download files into an Azure Storage account from my API created from an Azure Function. For context, users will first sign in using B2C, and then the user will be redirected to my API's html home page, authenticating the user though the B2C JWT token. The home page will have two buttons, redirecting the user to either an upload or download HTML page depending on what file action they want to perform. Finally, based on the information they input on the upload/download HTML page, they will either get a file downloaded from the storage account or upload a file. For additional context, the storage account's containers only accept AAD authorization, and the Azure Function will be granted an Managed Identity with Blob permissions to manipulate the storage account.
What I was wondering, however, is where should I place the code to not only upload/download a file, but for authentication? I was thinking the Azure Function would authenticate the user before performing any action, but then to perform specific file actions the user needs to submit information through the HTML pages such as the container they are associated with, the file that they want to download/upload, etc. Is there a script source for HTML pages that I could use to load Azure Storage actions?
Please let me know if I need to explain myself further, as I was not sure if this explanation was 100% understandable.
A user's previous comment suggested that I use a secondary Azure Function which is what I am trying to do now. So the Azure Function that acts as the API contains the HTML pages, and then the users will submit their information through the HTML pages to interact with the secondary Azure Function, which will perform the file manipulation on the Azure Storage account (downloading/uploading files).
I'm wondering how the secondary Azure Function will return downloaded data through context.res. For upload I've done something similar before, however how can I get a file downloaded from the storage account?
Sign in to comment