0
votes

Is the following scenario possible in azure?:

I need to build an app that will do some heavy processing behind based on user submission and return the results as a file to user.

  1. Step 1: User submits the data via REST call to my endpoint (asp.net web api)
  2. Step 2: Web role return's the url to the report (that was not created yet!)
  3. Step 3: My endpoint passes the work to worker role and do the heavy job (2-3 minutes)
  4. Step 4: Worker role ends the job and creates a report file and upload it to azure storage blob
  5. Step X: THIS IS WHAT I NEED TO KNOW IF IT'S POSSIBLE: At Stept 2 after the user makes the call I need to return the url to the report which is not created yet, right away (I don't want user to wait for minutes or run in time-out issues). I know that that report file will be unique and therefore I need to know if I can generate the url to the azure blob storage to my report123.docx that has not been created yet ? However after 2-3 minutes when the report is ready, the user will be able to access that report with the generated url from step 2.

Something like: after the user make's the call the service will respond: here is the url to your report come-back in 2 minutes ...

1

1 Answers

5
votes

Sure, this is possible. I can create lots of blob storage URLs right now --- http://account1.blob.core.windows.net/Reports/john1.pdf, http://account2.blob.core.windows.net/Reports/jane3.pdf, ...

I assume you know the storage account name, container, and final blob name that you want to use? If yes, just return that to the user in the form of a URL (you can use GetBlobReference in the Storage Client DLL to do this). You could even put up a temporary dummy report that says something like "Report not finished, check back later" in that blob, and then replace the blob once the report is done.

But may I suggest a better way? Change your Web API to by async. Your clients would submit the job and you would return an ID. The clients would then call another API to check the job status, and once the job was finished they would get back the URL. Look at the Azure Blob services's Copy Blob API (or any of the Azure Service Management APIs) as a point of reference.