Chapter 7. Creating a microservice

 

This chapter covers

  • Writing web services with ASP.NET Core
  • Making HTTP requests to web services
  • Introduction to creating microservices

My personal blog is written in .NET Core (http://mode19.net). Originally I wrote each post in its own page. Those pages were all part of the source code of the blog and had corresponding metadata in a database. But as the number of posts increased, the site became hard to manage, especially since the older pages were written using older libraries and techniques. The contents of the blog posts didn’t change—only the formatting changed.

That’s when I decided to convert my blog posts to Markdown. Markdown allows me to write just the content of the blog post without having to worry about the formatting. That way, I could store my blog posts in a database or BLOB storage and not have to rebuild the web application every time I posted a new entry. I could also convert every page on the blog to use the latest libraries I wanted to try out, without touching the posts’ content.

To handle the storing of posts and conversion from Markdown to HTML, I created a microservice. To describe what a microservice is, I’ll borrow some of the characteristics listed in Christian Horsdal Gammelgaard’s book Microservices in .NET Core (Manning, 2017). A microservice is

7.1. Writing an ASP.NET web service

7.2. Making HTTP calls

7.3. Making the service asynchronous

7.4. Getting data from Azure Blob Storage

7.5. Uploading and receiving uploaded data

7.6. Listing containers and BLOBs

7.7. Deleting a BLOB

Additional resources

Summary