%3CLINGO-SUB%20id%3D%22lingo-sub-1371152%22%20slang%3D%22en-US%22%3EAPI%20Patterns%20and%20Technologies%20-%20WIN%20AN%20EBOOK%20PART%203%3A%20Hands-On%20Microservices%20with%20C%23%20and%20.NET%20Core%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1371152%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EThis%20is%20the%20third%20post%20of%20a%20series.%20In%20the%20first%20post%20%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-developer-community-blog%2Fwin-an-ebook-hands-on-microservices-with-c-8-and-net-core-3%2Fba-p%2F1323985%22%20target%3D%22_self%22%3EWIN%20AN%20EBOOK%20-%20Hands-On%20Microservices%20with%20C%23%208%20and%20.NET%20Core%203%3C%2FA%3E%3CSPAN%3E)%20%3C%2FSPAN%3E%3CSPAN%3E%2C%20Ed%20Price%20announced%20the%20survey*.%20And%20in%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-developer-community-blog%2Fthe-flixone-bookstore-journey-win-an-ebook-part-2-hands-on%2Fba-p%2F1349543%22%20target%3D%22_self%22%3Ethe%20FlixOne%20Bookstore%20Journey%3C%2FA%3E%2C%20Gaurav%20explains%20the%20sample%20and%20scenario.%20(Click%20%3CA%20href%3D%22https%3A%2F%2Fforms.office.com%2FPages%2FResponsePage.aspx%3Fid%3Dv4j5cvGGr0GRqy180BHbRxcqO9ZweDRPlDtvKt3zuzBUMzRIT0ZVSUU1TzBGU0MxSlRKUVA1TlZFSS4u%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%20to%20enter%20the%20contest.)%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGaurav%20and%20Ed%20just%20published%20a%20book%20on%20microservices%20in%20a%20.NET%20Core%20world.%20I%20did%20the%20tech%20review%20on%20the%20book%20so%20I've%20already%20had%20the%20pleasure%20of%20reading%20it%20%3A)%3C%2Fimg%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EReviewing%20a%20book%20gives%20you%20some%20insight%20into%20how%20much%20work%20is%20required%20for%20writing%20a%20book%2C%20and%20covering%20microservices%20is%20a%20topic%20you%20can%20write%20extensively%20about.%20My%20part%20in%20the%20book's%20making%20primarily%20required%20me%20to%20read%20a%20lot%2C%20which%20is%20less%20hard%20than%20writing%20it%20all.%20You%20face%20different%20challenges%20though%20-%20if%20a%20reader%20catches%20a%20glaringly%20obvious%20bug%20in%20the%20code%20they%20may%20very%20well%20complain%20%22what%20kind%20of%20blind%20reviewer%20let%20this%20pass%22%20so%20I%20had%20to%20put%20some%20effort%20into%20scrutinizing%20the%20text%20%3A)%3C%2Fimg%3E%20(If%20there%20are%20obvious%20bugs%20there%20still%20I%20will%20assume%20they%20were%20inserted%20after%20the%20pages%20passed%20my%20eyes.)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20should%20read%20all%20the%20chapters%20in%20order%20to%20get%20a%20feeling%20of%20the%20multiple%20facets%20required%20for%20being%20successful%20with%20microservices.%20But%20how%20do%20you%20get%20an%20actual%20real%20life%20feeling%20for%20it%20all%20(apart%20from%20the%20sample%20code)%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESome%20of%20the%20aspects%20with%20microservices%20are%2C%20let's%20be%20honest%2C%20in%20the%20theoretical%20department.%20Of%20course%2C%20this%20could%20be%20said%20about%20programming%20in%20general%20and%20dependent%20on%20what%20your%20role%20in%20it%20is%20as%20well.%20If%20you%20are%20the%20solution%20architect%20for%20a%20new%20platform%20that%20should%20be%20able%20to%20handle%20millions%20of%20users%20you%20will%20have%20different%20concerns%20than%20a%20developer%20trying%20to%20figure%20out%20why%20a%20given%20unit%20test%20is%20failing.%20Correspondingly%20it's%20hard%20to%20figure%20out%20the%20path%20when%20someone%20says%20%22lets%20rebuild%20our%20web%20platform%20into%20a%20non-monolithic%20microservices%20based%20architecture%22.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHow%20do%20you%20know%20if%20Service%20Fabric%20or%20Kubernetes%20is%20right%20for%20you%3F%20Should%20you%20implement%20the%20%3CEM%3E%3CSTRONG%3Eambassador%3C%2FSTRONG%3E%3C%2FEM%3E%20or%20%3CSTRONG%3E%3CEM%3Esidecar%20pattern%3C%2FEM%3E%3C%2FSTRONG%3E%3F%20And%20getting%20down%20to%20the%20nitty%20gritty%20-%20should%20you%20use%20Linux%20or%20Windows%20containers%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20book%20will%20obviously%20not%20be%20able%20to%20give%20you%20all%20the%20digested%20answers%20for%20what%20fits%20into%20your%20specific%20use%20case%2C%20but%20it%20should%20give%20you%20a%20background%20for%20reflecting%20upon%20some%20of%20these%20things.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELooping%20back%20to%20my%20own%20question%20on%20how%20to%20get%20a%20feel%20for%20this%20-%20is%20there%20any%20specific%20area%20to%20start%20with%3F%20As%20a%20consultant%2C%20my%20default%20answer%20is%20usually%20%22it%20depends%22%20(let's%20bill%20a%20couple%20of%20hours%20before%20getting%20to%20actual%20business%20right)%2C%20but%20I'll%20provide%20an%20example%20(free%20of%20charge)...%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAPIs.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%22Oh%20great%2C%20like%20we%20haven't%20been%20able%20to%20hook%20up%20some%20REST%20HTTP%20conversations%20in%20recent%20years.%22%20I'm%20pretty%20sure%20most%20devs%20have%20been%20consuming%20APIs%20for%20a%20while%20now.%20But%20there%20could%20be%20things%20you%20haven't%20dug%20into%20yet.%20Take%20for%20instance%20the%20%22ASP%20.NET%20Core%20Web%20Application%22%20template%20in%20Visual%20Studio%202019.%20You%20have%20a%20couple%20different%20options%20(MVC%2C%20Razor%20Pages%2C%20etc.)%2C%20but%20even%20if%20you%20tick%20off%20the%20box%20for%20Docker%20Support%20you%20essentially%20have%20something%20that%20tries%20to%20lead%20you%20to%20build%20a%20monolith.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20not%20saying%20it's%20bad%20code.%20It's%20actually%20great%20that%20you%20can%20have%20a%20basic%20%22Hello%20World%22%20type%20web%20app%20up%20in%20a%20couple%20of%20seconds.%20It's%20not%20a%20bad%20starting%20point%20for%20other%20things%20further%20down%20the%20line%20either.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20you%20start%20adapting%20the%20boilerplate%20to%20your%20needs%2C%20and%20then%20it%20strikes%20you%20that%20maybe%20you%20want%20to%20separate%20the%20backend%20(API)%20and%20the%20frontend%20(UI).%20This%20means%20that%20you%20should%20be%20thinking%20about%20something%20like%20%3CSTRONG%3E%3CEM%3Ewhat%20makes%20a%20good%20microservice%3C%2FEM%3E%3C%2FSTRONG%3E.%20You%20probably%20want%20to%20split%20the%20API%20and%20the%20UI%20into%20different%20projects.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOk%2C%20you%20run%20the%20Project%20Creation%20wizard%20again%20and%20have%20a%20separate%20API%20project.%20Are%20there%20more%20things%20to%20think%20about%3F%20Well%2C%20most%20API%20calls%20will%20be%20read-only%2C%20but%20there%20will%20be%20some%20write%20actions%20with%20complicated%20logic%20for%20validation%20before%20persisting.%20For%20the%20read-only%20part%20you%20should%20probably%20look%20into%20having%20a%20%3CSTRONG%3E%3CEM%3Ecaching%20mechanism%3C%2FEM%3E%3C%2FSTRONG%3E.%20Should%20you%20do%20separate%20services%20for%20reading%20and%20writing%3F%20What%20is%20the%20proper%20%3CSTRONG%3E%3CEM%3Esize%20of%20a%20microservice%3C%2FEM%3E%3C%2FSTRONG%3E%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20now%20you%20have%20two%20microservices%20for%20the%20API.%20But%20how%20about%20accessing%20them%3F%20It%20would%20look%20sort%20of%20silly%20if%20you%20told%20the%20frontend%20guy%20that%20there%20are%20separate%20URLs%20for%20reading%20and%20writing.%20So%20maybe%20you%20need%20an%3CSTRONG%3E%3CEM%3E%20API%20Gateway%3C%2FEM%3E%3C%2FSTRONG%3E%20to%20put%20in%20front.%20Many%20APIs%2C%20possible%20multiple%20gateways%20-%20sounds%20like%20this%20will%20be%20quite%20the%20management%20task.%20Which%20is%20why%20we%20have%3CSTRONG%3E%3CEM%3E%20API%20Management%3C%2FEM%3E%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20book%20goes%20over%20the%20examples%2C%20which%20are%20available%20on%20the%20book's%20GitHub%20repo%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22API-Gateway_Examples.png%22%20style%3D%22width%3A%20450px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F189943i24C5D71A794B6B8D%2Fimage-dimensions%2F450x77%3Fv%3D1.0%22%20width%3D%22450%22%20height%3D%2277%22%20title%3D%22API-Gateway_Examples.png%22%20alt%3D%22API-Gateway_Examples.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet's%20call%20the%20backend%20sorted%20then%20and%20talk%20frontend.%20You%20need%20HTML%2FCSS%2FJS%20to%20do%20this%2C%20and%20doing%20autoscaling%20to%20fit%20different%20screen%20resolutions%20is%20easy%20enough.%20But%20you've%20been%20thinking%20that%20on%20mobile%20devices%20it%20might%20be%20even%20better%20to%20create%20a%20native%20app.%20You%20could%20wrap%20the%20regular%20web%20view%2C%20but%20you%20want%20to%20optimize%20data%20traffic.%20There%20are%20actions%20you%20just%20don't%20need%20to%20do%20on%20a%20mobile%20so%20you%20sort%20of%20feel%20like%20you%20need%20a%20separate%20API%20for%20the%20mobile%20app.%20Have%20you%20looked%20into%20the%20%3CSTRONG%3E%3CEM%3Ebackends%20for%20frontends%3C%2FEM%3E%3C%2FSTRONG%3E%20pattern%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERight%2C%20we%20have%20a%20number%20of%20APIs%20and%20a%20number%20of%20microservices.%20You%20get%20that%20this%20is%20where%20you%20suit%20up%20for%20%3CSTRONG%3E%3CEM%3EIntroducing%20Docker%20%3C%2FEM%3E%3C%2FSTRONG%3Eand%20deploy%20your%20services.%20Is%20this%20also%20the%20time%20to%20look%20into%20how%20you%20can%20wrangle%20all%20these%20services%20and%20look%20into%20Azure%20Service%20Fabric%20and%20%3CSTRONG%3E%3CEM%3E%3CSTRONG%3E%3CEM%3EAzure%20Kubernetes%20Service%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FSTRONG%3E%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20above%20scenario%20reads%20more%20like%20a%20thought%20experiment%20than%20a%20recipe%20-%20I%20get%20that.%20Thing%20is%20it%20should%20be%20something%20you%20can%20start%20playing%20with%20without%20designing%20a%20fancy%20system%20first.%20You%20can%20mock%20both%20the%20reading%20and%20writing%20part%20of%20the%20API%2C%20and%20if%20you%20don't%20actually%20know%20how%20to%20build%20a%20mobile%20app%20you%20can%20fake%20that%20too.%20Not%20every%20buzzword%20I%20dropped%20was%20directly%20related%20to%20APIs%2C%20but%20you%20should%20be%20able%20to%20see%20how%20it%20is%20a%20lot%20to%20explore%20in%20that%20area.%20The%20terms%20in%20%3CSTRONG%3E%3CEM%3Ebold%20italics%3C%2FEM%3E%20%3C%2FSTRONG%3Eare%20ripped%20right%20from%20the%20Table%20of%20Contents%20for%20Gaurav%20and%20Ed's%20book.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDid%20I%20mention%20you%20can%20win%20a%20copy%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fforms.office.com%2FPages%2FResponsePage.aspx%3Fid%3Dv4j5cvGGr0GRqy180BHbRxcqO9ZweDRPlDtvKt3zuzBUMzRIT0ZVSUU1TzBGU0MxSlRKUVA1TlZFSS4u%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EHere%3C%2FA%3E%20is%20the%20link%20to%20the%20survey*%20again.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3E*%20Please%20take%20a%20few%20minutes%20to%20complete%20our%20survey.%20Please%20ensure%20you%20are%20authorized%20to%20provide%20this%20information%20and%20not%20violating%20any%20company%20policies.%20Your%20responses%20will%20be%20kept%20confidential%20with%20restricted%20access.%20For%20more%20information%2C%20see%20the%20Microsoft%20Privacy%20Statement.%20If%20you%20have%20questions%20about%20this%20survey%2C%20please%20contact%20TechCommunity%40microsoft.com.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1371152%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3ESome%20of%20the%20aspects%20with%20microservices%20are%2C%20let's%20be%20honest%2C%20in%20the%20theoretical%20department.%20Of%20course%2C%20this%20could%20be%20said%20about%20programming%20in%20general%20and%20dependent%20on%20what%20your%20role%20in%20it%20is%20as%20well.%20If%20you%20are%20the%20solution%20architect%20for%20a%20new%20platform%20that%20should%20be%20able%20to%20handle%20millions%20of%20users%20you%20will%20have%20different%20concerns%20than%20a%20developer%20trying%20to%20figure%20out%20why%20a%20given%20unit%20test%20is%20failing.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1371152%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESoftware%20Architecture%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Senior Member

This is the third post of a series. In the first post (WIN AN EBOOK - Hands-On Microservices with C# 8 and .NET Core 3) , Ed Price announced the survey*. And in the FlixOne Bookstore Journey, Gaurav explains the sample and scenario. (Click here to enter the contest.)

 

Gaurav and Ed just published a book on microservices in a .NET Core world. I did the tech review on the book so I've already had the pleasure of reading it :)

 

Reviewing a book gives you some insight into how much work is required for writing a book, and covering microservices is a topic you can write extensively about. My part in the book's making primarily required me to read a lot, which is less hard than writing it all. You face different challenges though - if a reader catches a glaringly obvious bug in the code they may very well complain "what kind of blind reviewer let this pass" so I had to put some effort into scrutinizing the text :) (If there are obvious bugs there still I will assume they were inserted after the pages passed my eyes.)

 

You should read all the chapters in order to get a feeling of the multiple facets required for being successful with microservices. But how do you get an actual real life feeling for it all (apart from the sample code)?

 

Some of the aspects with microservices are, let's be honest, in the theoretical department. Of course, this could be said about programming in general and dependent on what your role in it is as well. If you are the solution architect for a new platform that should be able to handle millions of users you will have different concerns than a developer trying to figure out why a given unit test is failing. Correspondingly it's hard to figure out the path when someone says "lets rebuild our web platform into a non-monolithic microservices based architecture".

 

How do you know if Service Fabric or Kubernetes is right for you? Should you implement the ambassador or sidecar pattern? And getting down to the nitty gritty - should you use Linux or Windows containers?

 

This book will obviously not be able to give you all the digested answers for what fits into your specific use case, but it should give you a background for reflecting upon some of these things.

 

Looping back to my own question on how to get a feel for this - is there any specific area to start with? As a consultant, my default answer is usually "it depends" (let's bill a couple of hours before getting to actual business right), but I'll provide an example (free of charge)...

 

APIs.

 

"Oh great, like we haven't been able to hook up some REST HTTP conversations in recent years." I'm pretty sure most devs have been consuming APIs for a while now. But there could be things you haven't dug into yet. Take for instance the "ASP .NET Core Web Application" template in Visual Studio 2019. You have a couple different options (MVC, Razor Pages, etc.), but even if you tick off the box for Docker Support you essentially have something that tries to lead you to build a monolith.

 

I'm not saying it's bad code. It's actually great that you can have a basic "Hello World" type web app up in a couple of seconds. It's not a bad starting point for other things further down the line either.

 

So you start adapting the boilerplate to your needs, and then it strikes you that maybe you want to separate the backend (API) and the frontend (UI). This means that you should be thinking about something like what makes a good microservice. You probably want to split the API and the UI into different projects.

 

Ok, you run the Project Creation wizard again and have a separate API project. Are there more things to think about? Well, most API calls will be read-only, but there will be some write actions with complicated logic for validation before persisting. For the read-only part you should probably look into having a caching mechanism. Should you do separate services for reading and writing? What is the proper size of a microservice?

 

So now you have two microservices for the API. But how about accessing them? It would look sort of silly if you told the frontend guy that there are separate URLs for reading and writing. So maybe you need an API Gateway to put in front. Many APIs, possible multiple gateways - sounds like this will be quite the management task. Which is why we have API Management.

 

The book goes over the examples, which are available on the book's GitHub repo:

 

API-Gateway_Examples.png

 

Let's call the backend sorted then and talk frontend. You need HTML/CSS/JS to do this, and doing autoscaling to fit different screen resolutions is easy enough. But you've been thinking that on mobile devices it might be even better to create a native app. You could wrap the regular web view, but you want to optimize data traffic. There are actions you just don't need to do on a mobile so you sort of feel like you need a separate API for the mobile app. Have you looked into the backends for frontends pattern?

 

Right, we have a number of APIs and a number of microservices. You get that this is where you suit up for Introducing Docker and deploy your services. Is this also the time to look into how you can wrangle all these services and look into Azure Service Fabric and Azure Kubernetes Service?

 

The above scenario reads more like a thought experiment than a recipe - I get that. Thing is it should be something you can start playing with without designing a fancy system first. You can mock both the reading and writing part of the API, and if you don't actually know how to build a mobile app you can fake that too. Not every buzzword I dropped was directly related to APIs, but you should be able to see how it is a lot to explore in that area. The terms in bold italics are ripped right from the Table of Contents for Gaurav and Ed's book.

 

Did I mention you can win a copy?

 

Here is the link to the survey* again. 

 

* Please take a few minutes to complete our survey. Please ensure you are authorized to provide this information and not violating any company policies. Your responses will be kept confidential with restricted access. For more information, see the Microsoft Privacy Statement. If you have questions about this survey, please contact TechCommunity@microsoft.com.