Chapter 2: Microservices and Serverless Scaling Patterns
Activity 2: Implementing Asynchronous Microblog Submission and Caching
Create a new C# Azure Functions project inside a folder called MicroBlogPostFunctions and create a model called MicroBlogPost that accepts a post with a username (email address), title, and content:
Figure 2.50: MicroBlogPost class
Create a HTTP-triggered function named PostMicroBlogPost that submits these posts to an Azure Storage Queue named MicroBlogPosts:
Figure 2.51: Function that saves MicroBlogPosts to a queue
Create a function named DequeMicroBlogPosts that takes the posts from the queue and inserts them into a Cosmos DB named MicroBlogSite:
Figure 2.52: Function that dequeues objects and saves them into a Cosmos DB
Create a function called GetMicroBlogPosts that retrieves posts from the Cosmos DB in a list and uses the expires header to instruct end users to cache the response:
Figure 2.53: Function that retrieves all MicroBlogPosts and instructs clients to cache them