This is the classic dead end caused by this line:
Task.WaitAll(addPostTasks.ToArray());
try changing it to:
await Task.WhenAll(addPostTasks.ToArray());
Basically, Task.WaitAll blocks the flow of requests and cannot continue the Tasks initiated by await table.ExecuteAsync(...) . Another alternative is to use ConfigureAwait(false) for internal tasks to avoid switching SynchronizatonContext .
await table.ExecuteAsync(...).ConfigureAwait(false);
You can use ConfigureAwait(false) if you do not need to switch to the original SynchronizationContext . In your case, I believe that you can do this with all the expectations, as you are on the server, and it does not matter if the code is executed after await in the thread pool or not.
See this article for more information: msdn.microsoft.com/enus/magazine/jj991977.aspx
source share