Tuesday 14 April 2020

Race condition in ARM template

I was recently working on deployment of a web application and created an ARM template for Azure deployment and ran into an interesting issue.

AppGallery Deploy Failed: 'System.Threading.ThreadAbortException: Thread was being aborted.

This was a bit surprising. Why would ARM deployment run into ThreadAbort kind of issues.

After a bit of digging i noted this github thead

I ran into exact issue. Apparently the Azure deployment process ran the steps related to appsettings and MSDeploy in parallel and this caused a race condition resulting in this strange message.

Fix was quite simple - mention appsettings dependent on MSDeploy so that Azure deployment process runs them in sequence, thus avoiding race condition. You can refer the fix mentioned in the same github thread.

If you run into this problem, this can come handy.