title: Process multiple files in azure blob storage simultaneously based on custom logic
body: <p>My exact requirement is like this:</p>
  
  <p>I have bunch of files for my different customers in my blob storage "B1". Lets say 10 files for customer "C1", 10 files for customer "C2" and 10 files for customer "C3".</p>
  
  <p>I want to perform some operation on each file and move them to blob storage "B2". This can take 30 seconds to 5 minutes depending on data in file.</p>
  
  <p>Now I want to process one files for each customer simultaneously but not more then one file for the same customer at the same time.</p>
  
  <p>Like one file for customer "C1", one for "C2" and one for "C3" must process simultaneously. So the processing time of "C1" do not effect "C2" and "C3".
  But the next file of C1 will be processed only when the first is completed.</p>
  
  <p>What is the best architecture with Microsoft Azure functionalities to implement this?</p>
  
  <p>For example, I have implemented like this with Azure Function V1:</p>
  
  <ol>
  <li><p><strong>Blob Triggered Azure Function</strong> : This will simply add file names with customer ID in an azure table as soon as any file is placed in blob. This table will contain one more column "InQueue" which is FALSE by default.</p></li>
  <li><p><strong>Time Triggered Azure Function</strong> : This will check in azure table and take first file for each customer for whom all files has InQueue = FALSE (Means : No file in process). And for them update InQueue = TRUE and add their name to azure queue.</p></li>
  <li><p><strong>Queue Triggered Azure Function</strong> : This will be triggered as soon as any file is in azure queue and do the process on it. Once the process is completed it will delete the entry for that file from azure table. So, now for the customer of that file all other entries has "InQueue" = FALSE (No file in process)</p></li>
  </ol>
  
  <p>So in above architecture Time Triggered azure function is taking care of one file per customer but it is also pushing multiple files of different customers in queue. And as Queue Triggered azure function can run multiple instance at the same time. All files of different customers will be executed simultaneously.</p>
  
  <p>Is my architecture is good? or bad? or how can I improve it? What are the other options that can make my process faster or easier or with less steps?</p>