Azure Function with Blob Trigger2020-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:
The process can be summarised as:
- A request is made to a blog page (any blog page).
- The site's cached is checked for blog posts.
- If none are found then a request is made to Azure storage.
- The cache is then populated with the blog posts.
- 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:
- A blob trigger is attached to the Azure function.
- When the container is changed an event is raised.
- The event triggers the Azure function.
- The Azure function restarts the Azure Web App.