Let's Learn .NET - Microservices

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Music] [Music] [Music] [Music] [Music] [Music] hello shane how's it going good how are you i am doing wonderful hello everybody who's joining us oh i'm seeing you join from all over the world this is amazing i'm so excited to have all of you here today uh good morning good evening good afternoon wherever you're joining us from in the world we appreciate you spending that time here today with us uh so what are we talking about here today shane uh today we're gonna talk a little bit about uh micro services and everybody should be uh seeing that word a little bit into their social feeds or their work feeds or what have you and really trying to explain uh at a high level uh about what are they why are they important uh should i be using them should i not be using them what are the tools and then beyond that we'll go through a couple of kind of run-through workshops on uh some of the learnings that we have on the.net website on how to build your first um microservice using.net amazing uh well that sounds really exciting before we get started um my name is jamie singleton uh i work for the community team on.net i'm joined with my co-worker shane yeah and i'm a principal cloud advocate on the on the devrel team or advocacy team and i lead the net and mobile advocacy space amazing so shane tell me what are microservices yeah so that's a that's a good question because there's a lot of there's a lot of terminology that surrounds microservices you know the word micro intends it to be small but it doesn't mean it needs to be small it's really about taking monolithic applications and breaking them up into smaller more deployable and and kind of single printable responsibility items so if i have like a customer service that's just getting my list of customers i might have an api related to that service as well as a database backing store and that is a single deployable unit and what that allows me to do is to make iterations on that uh and do deployments independently of the other parts of my application so i i think in i don't know a few words it's really about single responsibilities of a service in the backing store and not interrupting or causing breakage in the rest of your application so you can start by architecting your application that way or you can start to break off pieces of monoliths into that thing and i've got a slideshow uh that we can go through if you'd like to kind of walk through some of these points right yeah that'd be excellent okay let me see if i can share my screen correctly uh and let me get it up into the right place and hit the right button okay how does that look are we good all right yeah i can see it all right awesome so we already talked about who i am we've already asked this question so here's kind of an idea we've got a monolithic app this has all of our items in kind of one piece meaning that it's deployed as a whole it's huge it's got a ton of moving parts and they're all managed and maybe a single solution or a single project if you're brave enough um so to move the containers uh the move to containers you know recently has has really made all of us kind of rethink our our software architecture um and the industry itself over the last i want to say a few years but it's probably longer than that now um has really start to embrace that that pattern for for building scalable reliable services that's one of the advantages for us to have these these micro services uh a little example is i use a customer service let's say that i have an order service that's that's also sodium associated with my application i can scale that independently of like my customer service because i would expect that my order services if i wrote a really good application would need that scalability and i can just scale that one piece of the app without having to scale the entire application which may not need it and consume additional resources so as i mentioned they're independent they're immutable deployments within containers and we'll talk about some of the tools that we use in order to manage and create those um my next statement is is it says it's small now they're scalable and small in the sense of the responsibility of that service is small but it also allows your teams themselves to be small as well so as our applications grow in size there might be multiple technologies used for for each one of those services so i can have a really small team that's just us.net i might have another team that's focused on go or the front end and they can just work on their one little specific theme without having to have the knowledge of all of the other tools that we're using and the stacks um you know it's i would say it would be a challenge for us to find somebody who had a breadth of in-depth knowledge across all the types of technologies we're using in an app um microservices themselves uh it's really an arc architectural style um that again it has these collection of services again they're loosely coupled and loosely coupled meaning that that's that independence that i talked about like i can do my order service by itself i can scale that and deploy it as i need to but it's also organized around the business capabilities um you know i don't have one api that has a service a surface area that covers you know marketing and ordering and my my shopping carts and location services all those services should be independent by themselves again now as this relates to net we took an approach with net core to make it you know you build it was built really for for the cloud and suited for this type of deployment and development um and we can walk through a couple of those things as we go through some of our examples now is the monolith bad no not all no monoliths are bad i bet all of us have something installed at work or on our current computers that is a monolith we wouldn't know and it operates just fine um many of those those apps are uh it still exists today and and they were created um you know outside of of this independent deployable stuff and you don't need to migrate all of your apps to a microservices type of architecture if it's not broken don't fix it but there might be a piece of your app that does need to scale independently and that's where you can kind of take advantage of breaking that that service off into its own thing and and make it scalable outside of the entire app itself um this is kind of a traditional uh diagram of um of what a monolith looks like or what we've probably developed over the last many years where we've got a web app or a mobile app that hits some api and the api has a number of these business dlls that we just make reference to and they work on a single database when we move to a microservices architecture we start dealing with things like api gateways which is really a a facade over all of the other underlying services or aggregator might be another word for that there's also a database per microservice now the diagram here shows that a single database per service but that could also be a schema within a larger database as well so it is a specific chunk of your data stores that's related to uh the service itself and that as well should be able to be kind of independently migrated to the next versions as you move forward async communication there's http um as well as grpc is another um uh protocol that we can use for our services to talk to one another and or like things like eventbus um an important one yeah yeah um so what is a container let's talk about that um because we hear that a word a lot associated with uh microservices and deployments and when we look at something like a vm which i think most people now in the industry would understand what a vm is it's really just a virtualized piece of hardware and in order for me to scale it i have to create another vm and the time to create those uh is is a lot by comparison to something like a container a vm can scale in best case probably a couple of minutes where our containers can actually scale in milliseconds um so the containers virtualize the operating system and and the applications themselves is that unit of work that's what we're scaling itself now in a traditional you know kind of virtualized environment um we have the the agility across the the teams and things like that um and you'll see that our vms have basically this this stack of where the hypervisor sits on top of the host and the hardware you do have a limit uh to what this can give us uh that all the way down to uh the hardware itself um we have again the the low utilization of the resources and in a containerized oh sorry mr button in the containerize application world we can put all of the containers in a virtual machine everything still sits in a vm but it can be a very large vm and the container itself is the application itself is the only thing that scales i don't have to scale the host os as well as my application so they're they're deployed independently of the of the host the the containers really have a hook down into the host os themselves like the visualization you have here i can't take credit for that niche on our team is a master at doing this uh and uh i appreciate his his help um so as we as we start to scale our application the unused resources kind of scale as well they go up and down so they're lighter weight they can be scaled easily and i can move my application to multiple containers inside of a single virtual machine instead of having multiple virtual machines to manage um so that's a big advantage as well and a cost savings too because if i have i don't know 10 vms that's gonna be much more expensive than a single one running in multi multiple containers um here's a statement from gartner that they expected that more than 75 percent of of our organizations the world will be running their apps in a containerized production environment so just uh talk a little bit about the growth kubernetes is another fun word um that we hear about uh in the microservices world and that's really the platform where you deploy these microservices type applications you can deploy containers themselves onto things like uh app service and azure and run a couple of uh of containers there but when you get into large scale um there is a a kind of a step up to things like kubernetes on azure containers or on azure kubernetes service and you can see just here um kubernetes is in production in many recognizable companies and there's hundreds more than what's there um and we can also run it on any platform right obviously we prefer azure but if you have an application that is currently running in one of the other vendors uh that support is also there and is agnostic to the vendor there's no vendor lock-in and it's an open source project as well a huge community of people um continually supporting and building up this service so we have a couple of uh of resources and i think that we'll supply some links as well we've got a number of ebooks that are that are free to you to learn um how to kind of step this up in some of the bigger applications how to modernize your app um into containers if you're currently running on a windows platform etc yeah we actually just released all of these new resources over the last month on the event page there is the aka dot ms slash micro services underscore resources where you can find links to all of these as well as all of the links for this event as well yeah and i see in a couple of questions here uh let me get out of this slide deck so i can see what else is going on here yeah are you ready for some questions yeah let's do that all right let's go ahead um because we got some good ones in the chat so uh and feel free to post your questions in the chat channel we are monitoring that and then we'll go throughout the event and ask answer those as we get them um so a real good question here um by ismail is can a monolith web api talk to a microservice or must you use docker um yeah i think the question uh is interesting because yes uh can i if i have a big monolith and i want to create a microservice now microservices means that i'm actually running in a container um and that allows us to do that deployment and all the architecture we talked about um your your application conversations uh will happen across http or grpc um you can uh if you can basically see the app either via ip or name resolution you can talk that service it's just like developing any other services that talk to one another the question of do we have to use docker um not necessarily right um i can create a single deployable um web api app that i can run on app service and i can scale that um but you don't get the benefits of uh the this very very small and kind of automated scaling that comes with some of that some of the container technology that's out there all right i see um i have a couple more for you um irvine olympus asks how do databases work with microservices are they using the same database or different databases yeah um good question i don't know what popped up on the screen another different question um that's a different question so answer the database question first because i did talk about it in this live presentation um the short answer is yes meaning that it can be its own database um or it can be a schema within a big database and if you look at some of the um database platforms that are out there they may be able to give you the opportunity to to break up your uh database tables and stores into its own schema so they can kind of operate independently but inside of a big box um now as far as databases different databases this comes into like maybe i'm running sap or some hr system that i don't control i might have a service that just talks to that one thing and exposes the functionality for me all right see now so we have another question um by react land was actually our first question um so are microservices and server lists basically the same in the system design view ah good question um so serverless and in our world of being azure functions um it does certainly fit into the microservices architecture because that is its own thing right that you might have an api built specific to a task in in serverless it gives you the scalability it gives you the responsiveness uh and things like that what you don't have to worry about in the serverless world is i don't have to care about any servers right kind of like one of our colleagues jeff says serverless just means i don't care about the servers um there are servers there but it does allow you to not have to worry about what os i'm running on or what i'll have to allocate for memory or anything like that because that's all taking care of you for the platform and you would you would actually communicate with those uh via http call or grpc uh in the service serverless world we have our uh it would be via http for now um and and it's just like calling another web api okay okay we'll take a couple more questions and then and then we'll get going so um alexandros asks are microservices a good option for fast development yeah fast is relative um i would say it's it's good for um focusing on on one responsibility of your app so you're not distracted by what is my front end doing what is my back end doing what is that other service doing so when you're trying to uh focus on again just maybe just the order service that's all i really have to care about because they are there's no dependability between the different parts of your application other than just some sort of a url call that happens out there so um i think that fast yes there are things that certainly will increase your velocity as a developer um to use a devops term um when it comes to uh building out applications okay i'm gonna ask one more here before we get started on the next uh on the first workshop sure um bassant asks in which scenarios should we go for microservices um yeah that's a loaded question that's a loaded question um you know it's it's going to be things like uh apis it could be um any anything that needs to do work uh to support another application but you need to to think about how do i organize my services around my business capabilities so um if you need the scalability the high scalability ease of deployment so when you get into devops for microservices they're super easy to deploy um i'll give you a quick example uh i'm sure nobody who's on this call with us or this presentation with us has ever had a problem where they had to roll back an application um that's where i see this as a big advantage um you'll see how we kind of tag our containers and our images as we move forward through the demos but imagine if i have to roll back a deployment if all i had to do was change a version number um in a configuration and i could restore my app to its previous state that is a that's a big deal because typically you're uninstalling things reinstalling things turning machines on and off in the right order a lot of you know what we used to do in the past type of thing i see all right um okay so um we'll continue to answer questions throughout the event um so quickly uh i just want to give a couple a quick couple shout outs one um we are still doing the learn challenge um so if you have heard of the learn modules um we're doing this learn challenge where you get to complete the modules and you get prizes it's really awesome um complete with the badges um so there's the link right there um feel free to go ahead and go ahead and do that i also want to give a shout out to our watch party uh hello friends thanks for watching um and i think we have the link posted for the next workshop um so we're going to be building our first microservice yeah i think uh let's do this let's uh we can share my screen here and wait for that to come up there we go perfect so on the left is our microserviceswith.net i think we have a link we can share uh that i'll point you there um it's underneath the asp.net um area within dot dot net and uh there's a nice button here where there's there's a lot of information about kind of what we talked through already about why and what and and those good things there and there's even videos on here there's some guy i think i know who he is um how to build things with docker and stuff like that but what i'd like you to do is go and hit this get started button right so when i click the get started button it's going to take me to the very first tutorial and that's kind of what we're going to walk through today um in this first workshop here so we have our intro and it talks a little bit about what the prerequisites are for the intro nothing you're here okay um the intro is watch this video which we're not going to do we're going to skip ahead um so let's get started with that feel free to do the watch the video in your own time highly suggest yeah give me a thumbs up that would be great um so the first thing here is to install the net sdk now uh we have a link here that will take you to your platform specific uh download this we it doesn't matter if you're on windows linux or mac i'm going to be running through i'm on windows today and i'll be using powershell so once i do the installation of this here like actually let's open that new tab oh look it takes it downloads the exact sdk awesome so let's cancel that it'll install it for you on your platform and we get to see here actually trying to type in the wrong window if i said net uh we know that's installed here i can also say net let's see dash dash version and i'm using uh 502 5.0.201 so your latest one will actually get downloaded here you might be on a different version than i am i've got a number of things so let's get out of that we don't have an error so we can say continue which is great already doing great yeah already doing today um so the first thing that we're going to do is create a very simple web api um and this is kind of representative of some of the things that um some of the scenarios that we've covered in things like a people service and such like this in this particular case uh we're just going to create the um out of the box weather service that comes with the example so i'm already in my uh my working folder where i wanted to be and i'm just going to do a dotnet new web api the o tells us the output folder we want to put this here and we want my microservice i'm sure nobody's done that before and i'm going to doing a flag for no https i'm using vs code and doing terminal um but there are other tools like uh visual studio obviously and other community tools that you can go through the same type of scenario with uh and do like file new project and walk through some of the walkthroughs but the options themselves are exactly the same by specifying the o it gives me the the output folder but also the name of the application too um so i'll hit enter and it says it's getting ready awesome it's doing all these wonderful things and cool let me clear that and we'll do the next step and get into that uh my microservice so now we're in that folder and we can look at the generated code i need to just refresh this real quick with the folder all right let's close this out so if we walk through let me see if i can get a little more screen on here okay so the first thing that we can see is that we actually go to the uh controller the weather forecast controller um yeah sure let's uh there we go uh it looks like our typical um kind of web apr api type of controller we've got some basically some static summary some static data here uh we're using the the logger that gets injected to the ioc container uh and then here's our get method so this is the actual method that we're going to be calling um you know for today through the through the actual web browser um so we can continue we've done that this is great it says to run our services so i can bring up the terminal here and let's just clear this and let's do a net run now there are commands built into vs code that allows me to do this through uh the editor i'm just gonna go ahead and do it right here so let me make sure that i'm in the right thing there we go so now we've got uh our application we see it's running on localhost 500 and i'll just click into that and that's not cool we have a failure let's try this again classic it always fails when you are preserving never when you're running through it right so let's see definitely not i wonder if i have if you follow along the tutorial you'll see that you need to append something to that url magical producer behind the scenario scenes pay no attention to me so this is the magical error that i always get when i do api development and i don't actually go to the url of my api right because it's not on it's not on the uh the root it's actually in i think so my magical producer reminded us of that so now we've got our app running and we've got our apis coming back you can see our summaries here balmy it's it's all random if i hit refresh we should get some different weather um i would like on days to be able to hit refresh on my weather so let's get out of that let's go back to our tutorial and make sure we follow the instructions i should have clicked we ran into an issue that's what i should have done right but we didn't we're all learning here today i'm learning that after many many years of doing this i still can't remember to go to the right url when i'm testing my apis so this can be solved in your your tools of by setting a start page which i also did not do so hit continue and now we have to install docker so if i go and look at what we need we need docker for docker desktop to create our actual containers and have the tooling that we need locally uh in order to turn this into what is known as the micro service container for deployment um i have already gone to docker for windows it might say docker for mac or linux depending on what you're working on and that will take it to take you to here and you can just say which one you'd like to install so if i go and clear this out and do docker diversion just to make sure that we're still good and it's running this is great so now i have version 20. and i can actually the next thing i want to do is i'm going to push this to uh to docker hub all right shane can you explain a little bit about what docker is quickly yeah exactly what i was going to do so docker is um it's an application uh i want to call it a framework but it's a it's a way it's an engine that allows you to run these containerized applications locally on your machine but also gives you the ability to create the containers that you need for deployment so it is a really specific tool they they pretty much um it's i use the containers and and docker is kind of like the word kleenex and tissue right then there might be a lot of issues but everybody knows who kleenex is um so it's really just think of it as a tool that allows you to create these containers run them locally and then also they have registries and things like that you can deploy your containers to which is what we're going to do in the next tutorial not this one okay all right great uh and there's docker tooling built into um into vs individual studio through some of their workloads i have an extension for docker nvs code which allows me to do some easier things like creating my containers and i don't have to remember all of the command lines in order to do that so if you're using an ide that's that we haven't talked about definitely check out the other resources they may have those tools for you but at the lowest level you still need docker for your platform installed all right so only docker installed to continue yeah okay yeah um so now that we're got docker installed we've verified that we've got it running here the the next thing i want to be able to do is create the docker file which is really just a list of instructions on how to package up my application into a container and we can just use the echo dot here and we'll say we want to create the docker file and if i think it's this sorry if i go up to my things here you'll see we have a docker file that is in fact empty and that's what we're going to go ahead and add some content now you could use start to go there i'm already in vs code so i don't need to do any other work here um so let me get out of this and you'll see in the tutorial that we have a list of instructions and i'm going to copy those into the bigger window and then we'll talk about it paste this all right would people be able to use wsl instead of docker uh they can use docker inside of wsl right so wsl just allows you to run linux inside of windows and docker does run on linux as well in fact it was created originally for the linux platform oh okay yeah so i've taken the uh code sample here on the tutorial i've pasted it into vs code and we'll talk about a little bit what this does now the first thing in the line here is uh a from statement and it's specifying a kind of a url pattern here what this is saying is i need a base image uh a via a base image of the os and also the frameworks that i'm going to to use uh and in this our case we're using the uh sdkfor.net um uh version 5.0 so this is dot net 5 that i'm using and i you'll see that it says sdk here which means i'm getting the full sdk it's as if i have downloaded and installed uh the the net5 sdk and we're going to be using this and tagging it here as build the next thing here is and the instructions say it'll just create a work directory it's going to copy our cs proj into that work directory and then call a restore to basically do the nuget restore on our application right the next step here is we'll copy the rest of our app into this container here and then run publish with that same dash o parameter to a folder called app and we're using the configuration of release so we want to create a release version of it this is a multi-stage container bill which means i can define multiple from statements in here to do different operations in the next line here we have that similar url uh specifying the base image that we're going to be using in this case we're using asp.net 5.0 and this is a runtime version so this is going to be much smaller than the sdk by comparison we're going to again set that that app and then we're going to copy it says from build remember we specified up here at the top this is our build container and we're going to copy everything in the app folder to this app folder in our the stage here and then we're going to set an entry point and what this means is when the container is started this is the command or instruction that is going to execute on run so we have the my microservice dll and this is very important because we want to make sure that our folder our project name is named the exact same so you'll see my micro service see i already caught an error that might happen look at that let's go back there so we need to change that my micro server okay so yeah always validate that because in this particular case i'm using a linux based image and linux is um case sensitive so if it failed maybe just check your spelling of this so the the next thing that we're going to do if i look at my tutorial here is a create a docker ignore file and what this will do is similar to the git ignore where basically anything that gets copied from what see we do this step here copy everything there might be some files that just are irrelevant um that we don't need them actually in our build or our publish process so we want to make sure that we include those so um let's copy that command real quick and let's go here now we have this uh docker ignore file which is great and basically we want we want to exclude dot that looks good everything um these are the things that we want to exclude so our docker file that's not important to our build or our run step uh the bin and object folder also those are things that only happen on build and you may have debug and multiple types of releases in there so they're not important we don't want to put those actually in the container either we're going to try and keep this as slim as possible all right i'm going to pause here if we have any questions right now yeah i think um just waiting for a few people's local hosts to to catch up and also downloading the docker um what terminal are you using it's so crazy so um i'm actually using powershell um and i've added um oh boy it escapes me so if uh if you go and do a search for our good friend hanselman and probably uh powershell our shell oh there you go how to make it pretty fun your amount was purple right and there you go that's the exact same terminal um set up but basically it just has um the windows terminal he's using windows terminal i have it built into all of my uh setups here but this is basically oh my posh um and some other themes like uh paradox you can actually set it up for ubuntu in wsl and do the same thing so a good walk through there um i will see if we can share that out somewhere um as well awesome yeah i want mine to look that pretty i used to so i used to run on on on mac uh all the time and i had all the same kind of look and feel and what's nice about windows terminal is i can run inside of ubuntu or many other os's that we have uh flavors of linux in there and i can make all my terminals look the same or different depending on where i'm at uh the nice thing for me is i can switch back and forth between my mac linux or windows and i feel like i'm still in the same space which is really good that's really nice comfort right you have to be comfortable in when you're developing in your environment yeah um just quickly before we move on um is docker a specification or an implementation of linux it's well docker allows me if we go back to our docker file here uh i would say neither if i understand it right what this does is allow us to to say what we're going to use if i actually go and look at the container for net sdk 5 and i kind of look at all of the layers that exist for it we'll get down to a actually an ubuntu image that we're using so we're building on top of linux but what docker does itself is allows us to specify instructions in order for building our app inside of a container you can also do windows containers as well but those are a little larger in size um either i want to say they're right about a gig and a half maybe two gigs where this particular image is going to be somewhere i know in a range of 20 megs um so it's it's different there as well okay all right um let's jump to the next step let's actually see if we can create a docker image here um pull my my terminal up here and we're going to clear the noise um so the first command it tells us to do is a docker build dash team my microservice and then passes the dot now if i type this in here and say docker build and this is very similar like a.net build we're just telling docker what to do for us we have a dash t and what dash t means is that tags the image that we're building um so hey so it's easy easily defined you might get some random name if you don't use the tag um so i use tag and see my microservice and i could call this anything as long as i remember what it is and then i'm going to pass a context like where is my docker file where do i get my instructions so i hit the dot i'm actually in the same folder where my docker file is so i'm going to pass dot if i had it someplace else you can say dash f and give it the location but it has to be below where you're at it can't be above so kind of remember that for getting errors right it's a child with an apparent folder yeah you can't go up to above you right you can't go to another parent to call it uh got it so something oh goodness gracious okay hang on a second so what we have here is we have a unicode character somewhere did you save your file yes james i saved my file i didn't save my file thank you where's my i ran into an issue we're just gonna say contact the producer instead of that's it all right let's try it again oh get the same problem all right here i'm in the right place or docker file yeah we have save all really weird little definition i'm going to yeah we've got some unicode characters here somewhere we have some just suggestions try reformatting the file yeah this is a um it's there uh this is maybe a line endings problem one second here uh first line from has an invalid char yeah it's but it doesn't that's the thing is it it lies it lies lies all right let's do this i'm gonna do a cheat here next month's episode cheating while [Laughter] presenting okay so let's see if this works so i did basically use the docker tools in order to generate our docker file uh it has the same instructions here so now let's do a docker build here there we go magic to check that copy i'm gonna go there i think the copy might be getting us some some funky characters there so what this is doing is it's actually downloading the necessary items that we need that i don't have on my current machine so i might not have the uh the the base image that i need locally so it's bringing that down and then also uh doing all the dependencies that exist in there as well and then it'll actually execute the instructions that are there and then create my image and you'll see right here it's been writing the image there's your funky name that you might get and then it names it to something specific right so i clear and what we have to do next is we can look at docker images now docker images is just a command again it's going to list all of the images that exist on my machine uh and i'm going to widen this just a little bit so we can kind of see what's going on there and let's find there's my micro service you see it was built 33 seconds ago it's got a file size of 209 megs i'm sure there's some things that we could thin out of that to make it a little bit smaller you'll see that i've got some other ones on here that are much smaller 86 uh megs as well right so there's our container that we just created and now we have this you know my microservice which is all well and fine uh that we've got it packaged up in in an image but now how do we actually run it um and i think that's our next step here now you remember that when we first ran the app after i figured out what the right url was it was running on my port 5000 on my current machine and now what we're going to do is actually run the application in the container itself so if i did the commands that we have here and we'll actually copy this and paste it hopefully we don't get a bad thing you'll see we've got docker run it rm now this means i'm running it interactive i'm going to stream my terminal the terminal output from the container onto my screen the dash dash rm which will basically says remove the container from the running state once we exit exit the the app itself uh dash p will specify uh the ports and uh remember always that the left side of it is the outside port the port you're actually going to run and then port 80 is the port that is being exposed by the um by the docker container you'll see it says expose 80. we expose port 80 by default this is really not a necessary statement in this particular case but that's the port that we want to run if you're running something that has redis or some other type of a platform that has a specific port to run on you may or may not see that port specified so that's how you want to make sure you expose that the next thing i'm going to do is actually name the container this is helpful you'll see in a second when we see what's running to find what's running and then i'm going to pass the name of the image that we just created which is my microservice and you'll see that it's running right we've it was super fast actually faster than it was on my own machine and now if i go to the localhost 3000 where we're expecting to run that because that's where we said to run you'll see that we're getting the same results and now it's inside of the container it's not running on my actual machine running inside a container if i bring up the docker tools the docker dashboard here i'll drag this up here oh sorry that's not what we want so this is the docker dashboard you can see it's got my microservice container this is what we just ran and it's running on port 3000 and you can see the same terminal exposed here that we saw where we ran it from and where you might run it from we can also inspect and see the urls that are there that is actually running in a container and what net versions and things like that are running it on so this is a super great tool for looking at things like stats you can see that the memory usage of that container cpu etc and that's only within that specific container so all those isolated usage within that one thing all right super useful so if i just wants me to do a docker ps yes let me add another terminal here and what i just showed you inside of the docker tools is very similar as if i did docker ps and that gives me the running actually that i'm gonna pass the dash a those are all my running containers and we should have one of our other containers in here running if i didn't shut it down there it is my microservice says the port so it's running on there's 3000 it's wrapping a little bit sorry you see that it has that arrow to 80. what the name of it is and how long it's really been up so it's been up about a minute or so right that gives us that that information so ctrl c out of that leave that container all right at that point now we have actually created our container our kind of deployable item that we can put into kubernetes or app service and things like that this is the independent service that only gives us the weather so this is a very specific thing has no dependencies on anything else but also allows you to con continually iterate on this one particular project all right i think if i hit continue we we would be on to the next thing so yeah so we've reached the edge of our first workshop um let's take a couple moments here to answer some questions we have some really great questions in the chat um so um really quick though can you maybe walk through the steps of how you generated the docker file from vs code i just want to make sure that it's really clear yeah definitely i can do that and also i did i did find the bug here this is my fault producer's producer's fault the echo dot adds that invalid character so if you just create that fire file manually in vs code and then copy it it'll work just fine all right doing a pr now doing it live okay so how did i actually generate the docker file right that's a good question uh and that that speaks to the tooling that exists uh and available to vs code and visual studio um we have this docker extension and if i just go in vs code go to my thing here and i say let me look for docker i can choose that here and this is i just install this here it gives me the ability to kind of manage my containers do a lot of the terminal stuff i was doing all within vs codes kind of environment now how did i generate the actual file i first pulled up the command palette and i do that on windows by doing uh ctrl shift p in in on a mac as command jp and you'll see that if i type docker here's all of the things that i can do related to docker in my application and i just said hey add docker files to my workspace it's gonna ask me what platform am i using we're using asp.net core in this particular instance uh what operating system do i want to be my base operating system i chose linux because the images are very very small and i'm going to be deploying it to a linux based host and then it asks me what ports is your app listening on now as i mentioned you might have uh port specific apps that you're putting inside your container so you need to make sure you expose the correct ports we expose 80 by default uh this one also gives you the option for um the security port of 443. so i would just choose 80. um and then when i hit enter it says do i want to include compose files that's an advanced one that's if i'm doing multiple services together that i want to uh deploy and manage together i'm not doing that i'm doing a single one um and we already exist so we're not gonna say no don't overwrite my stuff and that's how it generates this uh in visual studio there's also the docker tools for visual studio where you can just right click uh your your project folder and say add container support and it walks through a very similar prompt in fact the video that was in the intro i walk through that as an example on how to do it with visual studio excellent thank you for walking through that it's much more clear to me now a few more questions that we have um what are the best resources to create docker images for legacy.net applications okay so yeah so non-uh core probably four seven and lower um those have to run on windows they have a windows dependency so there are docker containers um specific uh sorry docker images specific uh to uh to windows uh as well so instead of having this from statement that i have up here uh it would it would vary in order to make sure we're building uh for windows i believe the tag is the same it just knows when it gets built as for windows instead of linux so yeah there are windows-based net images that are available um i actually took talk about older applications i have an example if you just uh search on my github for nerd dinner and if you're familiar with nerd dinner that's like 13 years old or something um i actually put that in a docker container without any code changes and was able to deploy that to app service um so that was a lot of fun nerd dinner was can was actually created before github even existed so we had to pull that from our old repository source that i forget the name of oh wow i actually didn't know that it was settled um what vs code extensions are you using for this i'm not using anything specific for this other than the docker one that that i uh just like yeah if i look at my installed ones i have a lot of things right and i've got a lot of fun things some azure related things for deploying to azure databases kubernetes those might be useful later yeah there's a lot of um a lot of extensions that are out there that will be based on the the type of application you're writing it in you know frameworks there's a lot of fun things there's like millions of these things it's ridiculous so you need an extension for helping it's probably out there it's already in the library yeah [Laughter] um okay let's take maybe one more question before we move on so let's see um can you explain a little bit about the authentication over microservices and api gateway yeah so that's that's a good question um typically you wouldn't you know your the the facade or or api gateway uh that i spoke to in a quick presentation that's typically where you're going to do all of your authentication right so that's your entry point to your larger app um and there's there's support obviously for don't think of those things anything special as it relates to containers and how your applications exchange information if you're passing jot tokens or using um active directory those all those capabilities still exist the recommendation that i would have is if you're deploying things to to azure and doing a facade layer like api management api management has those kind of authentication uh capabilities uh available to you but what i would do and this is my opinion is if i'm building a facade that exposes all of my individual services underneath i'm going to terminate my authentication there um and then basically my the talking that goes between all of the services that exist inside of the container architecture like kubernetes those are all secure and they can kind of talk to each other without having any kind of boundary issues oh you're muted i got to say it and there's no recording that goes forth without someone doing that um so you're so all of those are available um just like within the library yeah yeah exactly exactly okay um so we will save time for more questions keep them coming um we will take time at the end as well to kind of really focus on all questions related to microservices um so next up we have our next workshop which we're actually going to deploy to azure um yeah look at that deploy to azure that's exciting yeah so if i hit this button here now also when you get to the bottom of these tutorials there's a lot of just resources of things that you would be uh interested in there's a link to the to learn all the learn resources for microservices and also those those docs and uh ebooks so be sure to do that so as jamie mentioned we're gonna we're going to jump into the azure space and start deploying our application um that's right to the cloud to the cloud and just for everybody who's joined us um more recently um all of the resources for this event can be found on the home page as well as if you go to aka ms slash microservices underscore resources all of the links for this event are in there as well as a bunch more um and for those learn challenge for those learn modules that were linked below we highly suggest that you do that because we're doing a learn challenge right now where you get points for completing your learn modules and that's exciting uh so yeah i think if i believe the link for the next workshop uh will be posted in the chat shortly and posted up here shortly um but yeah so we're going to move on to deploying a micro service to azure yeah so if if uh you don't get to the link uh just remember at the very bottom of that first one you just click on the button it'll actually take you to the next thing perfect all right so um now that we have our microservice in a container uh and that image has been built for us the next step obviously is to put it somewhere where it can run in production uh it's nice that we can run it on our machine and everything is fancy and no problems but we need to actually put it somewhere for production and the the first thing that we're going to do is push this to a docker hub repository now docker hub is a uh an image or container repository uh much like github is a repository for your code um we also have azure container sorry azure container registry which is the same thing but can be also private uh just like your code repositories there's public and private uh resources there um we're using docker hub in this instance because it's free and and uh we can just continue to move on without me putting in down a credit card somewhere great so um the first thing we want to do is actually uh quick question actually shane um do people they do need an azure subscription for this uh for this one we do i'm actually let's look at the cause we can point everybody to the free azure subscription that they can download hang on um yeah actually i think it tells us when we get to the setup azure tools okay great i just want to make sure that no worries we're not going to charge anybody for azure it is free and available all right in this particular case yes um so the first thing we're going to do is you can create a a docker hub account again it's much like a code repository account uh i happen to have one so the first thing i want to do is actually log into this into my account oh clear shane can't write pull this up and we'll say docker login so i have my credentials save and super secret on my machine so it automatically does it but you could be prompted for username and password that's there now that we've we're logged in i can actually now tag my image with my docker username and the repository of where i want it to be pushed right in this particular case is my microservice um so we'll just do uh let me copy that first one because it's more than i want to type and my username again think of think of code repository same idea and hit enter so now what that's done is it tagged the my microservice image with this sp or my microservice your tag has to correlate one to one with where we're pushing it in docker hub if if i had it named something different i just want to when i push it i want to make sure that it matches where i'm pushing it so now i'm going to do docker push and i'm going to push it to my organization slash where i want it to go and what's neat about this is we um we're only pushing our parts of the application because these are all built in layers you'll see that we have different entries here these are the individual layers of uh the image themselves so it's pushing everything there if i decided to change my application and hit push again there may or may not be layers here that say from cache which means that that layer already exists there there's no need for us to take that additional hit for us to push it up and i'm sure there's some cache pieces here because i think this is right around 270 megs and that would take a little bit more time than than most depending on your uh connectivity so now i've pushed my image there and if i actually went to docker hub which is hub.docker.com and we signed in here thank you for not doxing me all right awesome i can go back and share my screen again um you'll see that there's the my microservice i just updated that and it gives us all the information about it what's the tag this is the latest one and you can tag it with other versions so i could put like a colon at the end of um my the name of my tag and then put like 2.5 or whatever it is you'll see just like this right um you'll see the tags here uh and i think in our other one you'll see that the image is the compressed size there i go back to the docker hub oh great wrong one let's just go back here whoops there we go that's what i was trying to get to um you'll see that i've got some uh images here and it shows you how many times they've been actually been pulled uh this slash back in i think it's the back into nerd dinner it's been pulled over 50 000 times um so let's go back to our instructions here now we've got it there i went up and validated that it exists the other thing you can do is if you do the docker images um and look for um from microservice oh sorry wrong command wrong os if i scroll up you'll see that we have this here uh one thing i'll explain is you'll see it says 209 here 209 here these are actually the same exact image it's not an actual copy of the other one so this is not uh 418 it's actually still 209 when you do tags like that there's just a little bit of metadata there all right so i hit continue and now we're getting into our free account and installing the azure cli [Music] so creating a free account uh literally if you go to azure.microsoft.com free you can get your free account there if you already have an account you just skip right past it and the other thing is the azure cli and now the azure cli allows us to interact with the azure resources and and push and pull and view and see all the things that we have within azure for you deploying your applications i'm already logged in so actually i should probably just make sure i'm already logged in you'll see that it pops the uh the browser passes some tokens and you've logged in and now it's gonna actually run an account uh access here so let's get out of this and i don't know why it just swaps to that one so i have the azure cli logged in because i did the easy login the next thing um that we want to do is actually cr install the kubernetes service cli they actually um yeah the kubernetes cli you can run this uh command and will actually bring down the resources that you need in order to install the kubernetes stuff and that would give you the kubernetes cli capabilities as well which we're going to need in order to do some work to deploy this and did you already have the cli installed on your machine i do yeah okay i have i have all of the things uh for for this um as with docker there are azure um extensions there's kubernetes extensions as well in vs code if that's the editor of your choice so what i'm going to do now is is create start creating those azure resources now this is going to be a step-by-step thing uh if you're using if your company or our location actually uses things like azure devops or github actions there are tools in order to do this in one fell swoop but this will give you an understanding of how things are organized when it comes to our app so the first thing i want to make sure i don't have this already defined it's very possible i'm looking for my microservices and look at that i did that already awesome so i've already completed this step here so we're going to do the az group create dash name which names our resources now our resource group is what we're creating here this is kind of a logical way to group your items in your resources within azure um this could be a a project name or even a location name depending on how you're operating and then the location here defines what azure region do we want to um actually deploy our resources to in this case it chooses west u.s um so let's you may or may not have all of the uh the resources uh locations available to you depending on kind of where your azure account lies if you're in europe or or uh in the in certain sectors like government sector et cetera so you can look at this particular command here list locations i've passed the out table because this gives me a kind of a human readable format by default it's json that comes out so that's why we pass the the output type of table so you'll see all of the things that i have access to based on my subscription and we can do any of names is what we want to pass here so depending on where you're at uh you want to make sure you're deploying your app to the to the region that is closest to your customer if you're scaling and getting into multiple instances of you might have multiple regions that you're deploying your app to and then using some some load balancing or other service that we provide to get the global traffic manager is that the right one all right um i have a bunch of subscriptions which i'm not going to put up on the screen um just for security sake but you can see the account list that you have access to um by doing the the list and dash dash all that'll give your subscriptions list and then you want to make sure uh of the subscriptions that you see this is how you set your default uh subscription that you're going to be using for this particular resource um and just a note to the producer we should probably do this before we do this you should set your your account i think it says it's optional that's great feedback for the producer yeah yeah um the man behind the curtain um and so the next thing we're going to do is i'm actually going to create a kubernetes cluster and what this allows me to do is specify the resources where i'm going to be deploying my application um we want it to be on kubernetes it gives me all the scalability and and tracing and all the wonderful things that are that are associated with microservice development architecture um so let me copy this and i'll put it on the screen so we can walk through it a little bit um we're calling aks which is our kubernetes service which we installed the tooling for earlier we're going to call create and then pass the resource group that we just passed that we just created the my microservices resources now you might want to name your something different because there is some one case only type of situations depending on the service i'm going to give it a name that sounds like a pretty good name i'm actually going to name this probably something different oh go here go back to this this is just in case somebody already created this right for learn the node the node count is the the number of vms uh that that we're allocating we're only doing one right now for this particular thing and we're going also going to enable uh this particular option uh this uh http application routing which allows us to expose our services to kind of to the internet and also have them talk to each other via dns et cetera and then the generate ssh keys gives us the ability to have access to the vms from our local machine so this may take a moment or so to create this while this is happening let's jump to some questions yeah definitely because we we have a few um let's see does docker need windows pro version or can you use it on linux you can use it on linux you can use it on windows uh if you go to the docker for desktop uh site when you go to download it i believe it specifies which versions of windows it supports i don't know off the top of my head okay so but it does it is supported at least by the normal windows version and linux and also mac as well right um another question we have uh what if my company doesn't want me to push public or necessarily publish to docker um are there other registries for this yes there is um so azure container registry uh is one that uh that we obviously is a service that we provide in azure um and that's where a lot of companies are really pushing their their their stuff because that is private you can set up the tunnels between azure and your on-prem resources uh so that that's really great to have that particular option github also supports uh hosting that that type of registry uh resource so you can look at that too and that can be also public or private okay great so we have that option uh i'll just let you know what i'm running through here i tried to deploy that cluster into my west u.s resources um and it's not allowed to i'm not allowed to have that in my west u.s probably because i've maxed out what's there so i'm just going to go to a different location i'll just relocate right so you're going to run that script again just yeah i just created a new resource group and i just have to um change that here okay but you can ask another question fine okay um would it make sense to have a microservice architecture without containers um that's kind of a an oxymoron by definition meaning that microservices architecture as it's defined uh are containers like images uh sorry application pieces um deployable and scalable you know containers um now the idea of having services that are independently deployable and have no dependencies um would be like uh uh what's called soa architecture right so they're all managed independently uh but the challenge i see with that is i can't although they are not dependent upon each other they are all related services and putting in something like containers and kubernetes allows you to manage all those resources instead of a single entity um so i would say no um because it just defies the actual definition of microservice architecture i see that makes sense to me um if we ran multiple instances would they use the same port number or different port numbers they would use actually the same port number because what happens in kubernetes is that the individual images get deployed on what's known as pods and when somebody asks for like my service it actually will automatically do the balancing amongst all the pods as it scales up and out so you would still expose port 80 because it's a web service in this particular case and that's the web port we're going to communicate on that's awesome sorry if i was just going to add one thing if you're running multiple containers on your machine obviously the only port that you can exp that you can access it is is a single port so when earlier in the example where we did a 3000 colon 80 i could do another port 3001 colon 80 and and run another container and that still gives me the capability of uh running both of them kind of on the same port inside but externally there had to be access through different ports i see okay uh we're still running it okay we still have um see if we are doing on premise for deployment should and or can we do microservices uh hang on a second what was that sorry uh if we are doing on premise for deployment should or can we do microservice use microservices um yeah should it shoot is one of those things like yeah um that's saying that you should always use containers and microservices um it depends on the architecture of your app like they're not necessary for you to be productive and create productive applications but if you want the scalability and velocity that that architecture provides then yes definitely do microservice type containers and yes you can deploy on-prem provided that you have um the application host framework set up properly like kubernetes you can run kubernetes locally on your on your own um uh own servers uh i would recommend maybe putting it in a cloud and doing some tunneling just because they can manage it instead of you but yeah you could do it on-prem for sure okay good to know oh we're still running so this might take some time more questions more questions okay we got we have more so we'll keep going um okay uh so you can ask is it a bad idea to put your database or datastore in the same container as your app i have been waiting for this question um i knew somebody was going to ask it so you wouldn't put it in your same container right because if you're doing it in your same container then it's an actual part of your app so that might be something like uh i've seen even my own applications years ago where i might have uh some sort of a a db file or some sort of db that can run inside of my own application uh a related question to this is should i put my database in a container um and the reason really you don't want to put your database in the container is remember these can these containers are immutable which means that they should be able to die and come back to life without you losing any information or experience when you put your database in the container the data files that associated with that if they are also in that container when it gets destroyed or scaled or what have you because there's auto recovery built into [Music] kubernetes and such that data will also go away now a solution to that is can i put my database in my container but my files that it uses outside and that's yes and uh you would basically volume map your data files to some other store like it might be azure storage or azure files or something like that and then when i run my container there's a command when you run it to say volume mount xyz to xyz and that's how you would get those together that makes sense you mute it again it's twice twice uh i don't want to hear people tapping okay uh it looks like we did um it worked though we got the rights to build yes in fact i was i was running another command to kind of see what status were in if you run this az aka the list it'll give you all of your uh kubernetes services and gives you the the status of where they're at and just so happens it was succeeded when i went to go check i was like i know you're going to check on me so i'm going to be doing it new all right so now it's there um and we have our our cluster is ready to go and now we have to create a deployment uh into create deployment instructions in order to push our container uh and run it there so i want to make sure we're in the right we are in the microservice area yeah and then i'm not going to copy and paste that instruction are just going to create a new file i think that the yaml file will work fine the the issue is that when you do echo dot with powershell it actually puts the wrong encoding on it not with a command prompt which is what i tested it on oh yeah yeah yeah so that is that was the issue there and we're fixing the docks just to say create the file manually so that is that was the issue that was fun uh we got a pr in and on the way so i guess i know we are fixing things in real time yeah this is amazing all right so now i have my deploy.yaml file um and i'm going to copy the instructions here we'll go through what these are let me close all this stuff up here all right so [Music] we have uh this is really again a set of instructions on how to deploy this to um to kubernetes um so we're basically telling what type of it is this is a deployment instruction we're giving it a name um how many replicas like how many instances of this do we want running right now we're just going to do one we're adding some metadata around labels and such the spec is the important thing here because i need to define what containers am i deploying and how do they run um so again what's the name of it the image is where we're getting our image from remember we just pushed that to docker hub and by default um this is going to look at docker hub unless you specify some other endpoints like azure has like uh i think it's called mcr.azsomething.io uh so your image is actually the full url of your name if i went over to docker hub and looked at this here it should tell me how to pull it um but yeah i would pull it with this right here on my micro service now it's automatically going to default to latest but if you have a different version you can put that there we need to specify what ports we're going to be running this image on so we tell the container parts 80 and then we're going to set some environment variables again and that's defining that the asymnet core urls is also 80. we have to give it some a selector so when the actual control plane of kubernetes is looking for the service by name it kind of looks there the three dashes here indicates that we're gonna create more instructions of a different type this is this could also just be a different file uh from from here down so we're not gonna make two files just make it one so we have a service what's the name of the service that relates to these pieces up here so if something goes wrong make sure your names are correct and spelled correctly we're specifying a load balancer this is basically a an infrastructure piece that allows us to run multiple instances of this so if i had a replicas of you know 15 here it knows how to balance that so that answers that question before about ports and then adding a selector of my microservice let me go back to our instructions so now we're actually going to run the deployment let me make sure i save this file here this and what we're doing here is we're calling we're using the kubernetes um cli people will uh debate if it's cube cuddle cube ctl keep something um i usually alias minus k it's a lot easier to type and then i say apply which means we're going to apply the file and we define the file that we just created up here so if all goes well it's been created that was super fast now what this does is this actually pulls the image from docker hub to um to my kubernetes cluster when it gets created it's created a deployment and it's created the microservice service as well so we can actually see what's going on here and we've got our load balancer that we're looking for for the service here and we're waiting for an external ip to be uh allocated for us right now uh this is the internal ip um and then uh the external ip is what happens here so and will the external ip be automatically syncs once it finds one yes you'll get another line that'll pop down and say hey that's been done this dash dash watch basically says we're waiting for this thing to be implemented um in it how much time does it take don't know sometimes i've had it happen within a minute or so sometimes it's been a little bit longer um and we'll just wait for that to come up so while we're doing that let's answer some more questions if we have them yay okay so we do have more questions keep the questions coming in we will have a q a at the end as well um so uh will all versions of the container exist on the server though all versions of the container of the container image will exist in your repositories in docker hub in um you know azure container registry things like that when you're actually creating the app itself um you can have multiple versions sorry only the version that's running will exist on the cluster so depending on what you've defined for your service will determine what's running there on your local machine is where you're creating all of these images uh and you can have you'll have however many you create and same with the with the repositories for the container images themselves however many you push there's however many of those hosts it only run one version at a time and if it scales it runs the same version across them i see so one version but it's multiple containers right depending on where you push it okay um so how do microservices relate to domain driven design yeah domain driven design is is uh another architectural style you could still put all of your services um around those business operations um and make them individually um i would say that the the ddd resources for for containers i would have to look up to get more information on how to kind of put those things together but you can still certainly deploy your application in containers regardless of how it's architected from a programming perspective okay um yeah it's like it's still waiting um okay uh tongue asks how do microservices communicate with each other um yeah that may this may have been asked or covered before um so if i have multiple microservices that are dependent upon each other um so i might have a worker service that's just doing work like taking things off of a queue um and there may be some like i don't know status endpoint uh if you're running inside the cluster the microservices themselves can be again just through a url called http call and they're called by name so this one here is called my microservice so the endpoint within the cluster would be you know http slash my microservices slash endpoint um where typically you're having to manage all those urls in when you're deploying things this just it's all resolution by name you can also use grpc which is just a different protocol it's faster it's binary um if you're doing service to service communication inside the cluster that's the best way to do that externally to apps it's more common at least for now to use http type calls and rest or things like that all right let me see yeah it's like how are we doing still waiting okay so are there other types of containers other than docker i think you mentioned this earlier but yeah there are some other um uh ways to create them and and one other popular one the name escapes me now um the only ones that that i've used quite honestly uh are the ones that i that i create using docker but there are other ways to generate the actual image file um the most common way to do is with the docker tooling is with the docker okay that makes sense yeah it's like you're the you're the docker king um next program in aks or docker where should i put my ssl certificates and handle auto renewal um that question i'd have to look up to be honest i'd have to look at the resources i know we have azure docs on ssl certs um to manage those within your cluster and things that's kind of above and beyond what we're doing here but yeah we definitely have some azure resources around aks and ssl certs that we can probably share um as we get closer to the end i will look that up in the meantime yeah it's like we can actually look that up and link that yeah yeah for sure uh i saw a question come through earlier um and ask the question uh how small should microservices be and there's a little bit of a play on words we talked about it earlier on uh it depends on what your what your measuring stick is right is it is it uh the the virtual size of your application is it the size on disk is it the number of classes or endpoints or things like that um it depends on how you're measuring your service if your service it can be as big or as small as you want from a coding size provided that it is isolated to a single you know business operation is kind of the the practices that are that are put forth of uh again i might be only doing a service that's for orders now my order service might be very large and very involved but it's only specific to the order service where i could have a customer service which is you know very small and specific again to the customers so there's no disk size requirement um i would say if you are getting in an app and you feel like this is a little big you might have some issues around uh scaling because the image that you create the container image that you create is what gets replicated so uh if you have a humongous one and i would have no idea what that number is um but if you have some scaling lag you might want to look at breaking up your application to some smaller pieces see where we're at jamie we're still pending we're at the mercy of waiting for this and this could be partially my fault for all the resources that i have going on there oh the fun of deployment yeah but the thing is is once it is deployed right once it actually is deployed then um managing it um is is fine now actually this is already deployed there we're just waiting for an allocation of um vip and do you have to wait for that ip allocation before proceeding yeah so i think that um uh in order to to show the application running in azure through a public ip this is the best way to do it um there is a way to forward this particular port to my machine and i cannot recall the command to do that so we are going to have to be patient it looks like let's see what direction yeah what does our power shell say yeah we're still pending at this point okay but we do have a couple more questions actually we have a lot of questions around databases like okay how do how do we connect do i need multiple databases uh can you just like elaborate a little bit more about those yeah um so there's a lot of um scenarios uh when it comes to developing apps i think one of with databases and containers i have an example on my blog and we've done it in a couple of like build and ignite things where i have a subset of my data um inside of a container so the data and the engine all exist inside the container for local development right so i might wanna work on a specific piece i only have a subset of my actual data or some test data in a container and that allows me to run things like sql server or or mongodb or something like that locally on my machine with actually without actually having to install those things on the machine itself because they're all inside the container if anybody's tried to install sql server on our local machine it takes some time to do but we have sql server now available in a linux container that allows you to run your your asp.net core apps and connect to that as if it was another server running anywhere quite honestly that's a really good practice for working with databases in in containers just using it for local development if you're going to run a container i i don't suggest running contain a database in a container there are so many services available that do all the hard work for you um you know things like azure sql and cosmos db um you can run those type inside of a container there's really no reason to because that's a service that's provided by a vendor uh us or somebody else uh that they do the management of the database engine and updates and security and all those things keep in mind that the container that you create is is almost like taking a picture of where your app is in that one point in time i could actually pull down a container using net core 1.0 and do dot and do docker run on it and it's still going to work just fine because all of my resources are combined in there i'm not relying on any other thing and the same as with the databases as well okay kind of imagine that like when you're playing a game and you make it to save yes you know that's exactly right no that's exactly right that's a that's a good one like i want to pick it up and keep going or you know pick it up and and see where i was you can do that too amazing you still penned in here no pending um see here still waiting what other questions have we got here yeah i was gonna say that's okay we still have some questions um [Music] how do we handle version numbers with microservices oh good question let's open up another uh window here while we're waiting for those to happen you don't do it by typing wrong that's that's one thing you don't do oh my goodness there we go all right so remember we did docker build and we passed this tag number i think originally it was like my micro service and then we passed the context where the docker file exists i can actually do a colon here and add a version of my image here when i talked earlier about rolling back deployments so let's say this is 1.0 so when i build that it's building my application with that particular tag so we're waiting for things to finish up here um and now i'll have a a 1.0 tag uh in addition to the colon latest tag so you'll see that all the way to the bottom here and microservices 1.0 so if i did um docker push let's find that command here where we do the docker push a few steps so now when i do the docker push i can say colon 1.0 oh i don't have that now uh it's going to push those tags of one of latest and also of the 1.0 now what happens is when you do the deployments um they do a docker pull right that pulls the image down and when you specify in your deployment files the image to be pulled i would just change this to 1.0 now i have a different version there if something went bad in my deployment i could just change this back to latest and reapply this particular file and it's going to back out the quote-unquote bad image and then put in something new so that's how you manage your actual versions it's very similar to uh the docker files here where we have how we tag our image right we have version five and there's you know 3.7 there's 401 there's all these different versions that we have up here and that's how we how we manage the different versions does that make sense i was on mute yes oh i'm getting am i echoing to you no i don't think so okay good um a few more questions uh clever compiler from twitch uh was were you thinking of podman as the docker alternative potential that's possible yeah there's again there's some a bunch of variations of tools and and things out there that um that you can use again to build and manage those things um so yeah it's possible okay um so lynn asks how would you create a front end as a microservice and deploy it and is that even recommended yeah um that's a very common question as well is that um we um i don't know it's a good question how would i say that so if i look at front ends let's say like it's a a blazer app or maybe angular or vue or something like that what you have to ask yourself is what is it that you're scaling and in the in the world of single page applications all of the work is done on a client so once it's down on the browser you know you can do what you need to do unless you're making api calls now those api calls would be should be calling microservices type of stuff but um you're not if you say scale my paw scale my application you really need to scale the front end now if it's something like uh some server based technology maybe it's like you use a bad example classic asp right classic asp everything was built on the server and rendered down so that might be something where you have to scale your application most of the front ends right now between blazer and the other static web app type of front ends i don't really see a need for it to be in a container but as a group of deployment resources it's still okay to do it just know that you're never going to scale that one particular container yeah because i guess that the front end isn't as much the scale as much as the back end for the data right right exactly um i'm going to try and see if i can get our port for us um yeah because we're so close we just need to scale uh the issues with scaling uh my micro service and let's see if this will work [Music] and i apologize for the lawn mowers because apparently they decided to show up early today happen to hear those uh 80. it works it's doing something waiting i was like i have one more question for you yeah no please do i'll be right okay uh in aks how do we next programmer asks in aks how do we set up different environments for dev qa pre-production et cetera you have multiple aks instances um simple enough um now the total like when we did our first creation and we said uh node count was one that might be more for production than it is for for dev or qa or something like that also you only want to keep them as equal as possible but you would definitely set up different actual environments or instances of your aks cluster for each one of those environments okay so they would need to be different yeah let's see if we're anywhere closer to where we need to be psy all right we're just here all right what i'm going to do here let me just do this because we can walk through the rest here okay um so once it's deployed and we're able to browse that ip that we're waiting on um and let's say we want to scale it the big weekend coming up we want to make sure we have proper resources what have you um i'm going to call uh use the the kubernetes cli i'll call scale say how many replicas i want and then define the actual deployment so if i go back to our deploy yaml file here you'll see that our initial replicas was one um and that can scale us to 2 or 20 or what have you uh and that gives us our scalability now there's some automation available on the platforms that allow you to say you know based on cpu based on um overall resources or ram or things like that there's these triggers that you can do to help scale your your applications up and down based on those those triggers as well but this is how you would manually do uh the my micro service i just i'll look at it with scaled so if i look at um cube ctl get all uh you'll see here now i've got two waiting to be allocated because we're waiting on our ip right now and i could scale it to 20 or 100 or what have you it's all based on um the needs and the load balancing of those services are all managed by kubernetes in the control plane so i think if we did cube tpl get pause we're still waiting for that to happen all right okay so hit continue for scaling and then this is a very important step if you're working through these uh tutorials and you're creating all these resources please make sure that you clean up after yourself when you're done as to not uh get unrecognizable charges so if i wanted to actually delete things here i would say az group delete that one uh in the actual name of your um uh resource group that we created that's why it's important to do resource groups and put things in a resource group that are related uh there's goods and bads if you delete the resource group everything that's in it also gets deleted so this would be inclusive of our cluster of um you know any special things like api management tools or monitoring tools that we put in that side of the resource group it will actually be deleted so i'll make sure i clean it back to myself after i verify things uh it's not where i want it to go and that's the end of that particular thing for kubernetes uh in deploying the app i i'm sorry we're still waiting on our on our ip i'll have to ping support about that and see what's going on there we did we did have a few people in the in the chat that have been following along at home and did say that they have deployed and they got an ip before you so oh that's crazy they're probably trying to hit my credit card or something and i've run out of allocated account resources okay perfect um do we have any more questions where are we how are we doing on the agenda here yeah so we have a few more questions i'll definitely take a few more um and then we'll close up here in about 10 minutes okay um congratulations everybody who is able to deploy your app to azure we apologize for the delay here except for me except for you no claps for china but congratulations everybody else you're amazing you're awesome you're so smart um i will uh feel free to send in your questions and we'll answer those as they come in so rothwell asks can you talk about authentication and microservice yeah i think um maybe they joined a little bit different or missed that yeah this is earlier yeah um it's very interesting when it comes to authentication uh because i think typically we we all think when we're creating a service we have to secure it uh so we're gonna run on ssl um or we might need tokens right for that um when you're doing authentication from an external app into your microservice architecture those same semantics should be followed right we you can use active directory or social accounts or all the authentication ways you can do active directory et cetera but that in my opinion should be done at the api management level or your aggregator service letter like what is the entry point to the rest of your architecture everything underneath runs kind of not in a sandbox is probably a bad term but it runs all contained by itself like inside of a fence so those can all talk http um without any uh you know ssl overhead uh unless you have to pass like tokens down further but the same same semantics of of authentication between your services should still be practiced um and if you're using something like api management uh there there are tools built into apim for things like active directory authentication for example to help you manage that too okay i see a question here you're muted again all right so the uh the next question i'll bring up uh looks like steven mentioned can i talk a little bit about service fabric and if it's something i would use instead of docker um i can't speak specifically to service fabric as i understand service fabric there's a lot of actor models as well but there's also some specific platform things you can do with service fabric if i was starting brand new i would probably go with a just a standard microservices approach service fabric does in fact run on you know the cloud and it's scalable and has a lot of the same features um but i would say it's recommended at this point i would say recommend it's a bad word um i would say we would i would if i was starting green i would i would go with a uh microservices approach over service fabric but that's just me i would say look at what's there and see if it fits your your needs uh and service fabric is a scalable model a lot of azure runs on service fabric too okay um virax asks can you talk about managing secrets across microservices and clusters yeah yeah perfect so secrets is a good thing and there's things like i might have api keys that i'm using for external apis kubernetes has a built-in way to do secrets there's actually a whole resource on that uh within their yaml so i can define secrets and do secret stores it's built into kubernetes uh if you need an external uh storage for your secrets you can use uh azure key vault and we have integrations with azure key vault and aks as well so you can still manage them the same way if you're going to manage across multiple clusters i would say use key vault across the microservices themselves you can just use the built-in kind of key stores that that kubernetes provides and we've got some really good programming model as well for uh for asp.net core and accessing kubernetes secrets we have good integration there yeah we do actually um can you kind of compare and talk to docker swarm and k-8s yeah so um docker swarm was a similar way to do uh deployments and management uh they they were somewhat of a competing platform uh early on i go back three or four years um the docker tooling supports docker swarm as well in a way uh but there i would say that kubernetes is kind of the the winner they are the de facto standard now for for this type of architecture management uh and deployment in fact the docker tooling docker a couple of years ago started building in the kubernetes support uh into their own tools uh above and beyond swarm so swarm was kind of an early thing there's another product out there called mesosphere which does a very similar thing i believe twitter created that and it runs on on mesosphere um but kubernetes now is kind of like call it the winner there's there was a three-person race and kubernetes seems to be in the lead at this point okay uh and i have um one last question for you before we kind of go to some resources i've been saving this one so manish thank you for your patience what are the cons of microservices oh i i saw this one coming i had to take a sip yeah cons of microservices first off it can be a shiny penny meaning that uh anytime something new comes out you know you may have the need or want to go oh there's this kubernetes thing let me go try it oh there's this you know xyz spot framework let me go do this um it's look at it and see if you need it right you can get into this fragmentation of how many thousands of pieces can i break my app up into when you might not need to right you just might not need all the scalability and everything that it does um it's good practice but you know i've seen a picture of somebody putting like a box on the back of a 18 wheeler and said i deployed my blog on kubernetes right a blog does not need kubernetes right a single page application doesn't need something like microservices and kubernetes um so i think the the desire to get there can be bad you can see some of the challenges we even had going to this there's things like these yaml deployment files the tooling uh is getting better and better but if i put a space in the wrong place of this yaml file i could get stuck for a while so that i think those are some of the cons um it's the the want versus the need you really have to to look at that um i would say that another con is there's a lot of opinions on how to do it as far as organizing your team versus your structure versus your devops process as much as your your application gets broken into pieces all of the other uh parts of developing that application get broke broken into parts as well so there has to be a common thread on what the goal is um that people can lose sight of when it comes to building and deploying the application yeah so kind of a structured idea of their end-all goal yeah exactly so they all communicate yeah amazing um well uh we're about time i want to make sure i share some resources here um thank you so much shane um you're excellent and this was all super super useful thank you secret producer behind the screen as well as our moderators in the chat also thank you everybody who joined our watch party yay we'll have more information on future watch parties um as well as future events this hap this event happens every month so stay tuned register on our website to get uh information about all of the events coming up next month um we have tons of resources that we launched this month including my team member nish's blog post about microservices we have architecture guides we have new learn modules we have updated documentation there's a lot of stuff and it's all totally available for you right there on the aka dot ms microsources underscore resources again don't forget about the learn challenge if you have some time to complete those um all of the resources that we discussed in this in this session we're actually uh on that resources link so feel free to head on over there if you have any questions for for me or shane going forward please feel free to reach out to us on twitter we're available for you if you had any issues running through the actual um tutorial we're happy to help step you through that as well thank you so much everybody who joined we really really appreciate you taking this time to spend it with us this is so exciting and i can't wait to join you next month thanks so much thanks steve [Music] [Music] [Music] [Music] you
Info
Channel: dotNET
Views: 47,582
Rating: 4.9564357 out of 5
Keywords:
Id: sstOXCQ-EG0
Channel Id: undefined
Length: 121min 2sec (7262 seconds)
Published: Fri Mar 26 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.