Azure Function with Blob Trigger

2020-01-02

Azure functions are a great way to encapsulate core non sequential functionality that can be run in a background process.

For my site I have a very simple architecture which I use for managing my blog posts, which looks as follows:

Old Architecture

The process can be summarised as:

  1. A request is made to a blog page (any blog page).
  2. The site's cached is checked for blog posts.
    1. If none are found then a request is made to Azure storage.
    2. The cache is then populated with the blog posts.
  3. A HTML response is returned to the user.

I had been looking at using Azure functions and decided that I would use them to perform the step of restarting the application whenever a new post was uploaded.

This gave me an excuse to use Azure functions and integrate it into my website's architecture.

So I wrote the following Azure function blob trigger hosted on GitHub.

This function works as follows:

  1. A blob trigger is attached to the Azure function.
  2. When the container is changed an event is raised.
  3. The event triggers the Azure function.
  4. The Azure function restarts the Azure Web App.