From the web page I make an API request that contains 2 params, one is file itself and one is email string that user provides. My API uploads the file to Azure Blob Storage and from there I need to trigger the blob storage function that will send the letter to email provided by user. How can I pass email to that function?
Imortant:
I can’t send email from API. My task is to send it using function.
2
Answers
You have a couple of options here.
The simplest would be to store the email address as a custom metadata property on the blob. Note that as email addresses are personal information you will want to make sure your storage account is secure.
Set in your API
Get in your blob triggered Azure function. Note you’ll have to use the BlobClient type in your trigger binding to be able to use this.
Alternatively you could look at storing the email in Azure table storage or other data store keyed by the name of your blob. Then look it up in your blob triggered Azure function.
I do want to add an alternative:
Have to api upload the json file to Azure Blob Storage and put a message on an Azure Storage Queue (or a Service Bus Queue) containing the name of the blob and the emailaddress to send it to.
Then create a queue triggered azure function with a blob input binding that reads the message from the queue and has a reference to the blob so it can send the email. This way you do not have to modify the blob, store sensitive information in it and keep a clean seperation between the blob and the email.