I have an Azure function that triggers from a Blob upload, said Blob contains a text file with miltiple lines, each containing information about a person. The function reads the file and inserts a KeyValuePair into an Azure queue per line.
Then I have another Azure function which is triggered by the queue I mentioned earlier, which is mass executed asynchronously as the first function stores thousands of KeyValuePairs into the queue.
What I want to do is, when each KeyValuePair is processed by the 2nd function, I want to write to a response file, which will be formatted the same way as the input file in the 1st function; each line contains information about a person. Therefore, every execution of the 2nd function would write a new line into the response file (which is a blob, too). How would you achieve this?
Sounds like you could use Append Blobs to add a line of text for each queue item.
Here is a sample binding that you could use (note inout
direction):
{
"type": "blob",
"name": "appendBlob",
"path": "container/{name}.txt",
"connection": "AzureWebJobsStorage",
"direction": "inout"
}
I assume you already have a good way to know when the previous file should end and a new file should start, probably part of the queue message.
On a side note, the order of queue processing is not guaranteed, so the lines in your output file might have different order compared to the input file.