Building Cloud Native apps with .NET 8 | .NET Conf 2023

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello hey everyone how's it going you can tell that we're live because F arrived at the studio 34 seconds ago and everybody is panicking running on coffee so thank you all for uh for joining us today there's been lots of excitement about net Aspire since uh the two best people in the keynote talked about it a little while ago and and today we are going to tell you a lot more so I'm Glenn condrin D David I am the PM lead I probably just smacked my microphone apologies um the uh I am the PM lead for the dot net platform team and I'm distinguish engineer on net yeah so let's without further Ado get into some slides for net Aspire my plan today is to talk for a little bit but as quickly as possible well maybe as quickly as possible get into demos the vast majority of this talk is just going to be in Visual Studio showing you what a Spire looks like and talking about it so you know get prepared settle in ready to see lots of uh lots of code live coding live coding all of the hilarity that will no doubt ensue right okay so first slide let's uh let's get going Valor is SL don't all right so the first thing I wanted to talk about is a little bit of the history of how we got here with Aspire and Cloud native in general so the we've been doing this for some time the probably almost since the beginning of net core I remember the very earliest examples of us getting Docker working where we had to explain what Docker was before we could show people the demo because they didn't know um and then this slide is just like a cherry-picked set of things that are examples of we've been doing a a lot of individual features bits and pieces all over the stack to try and make it better and more capable for building apps for the cloud for years and all of you have been building amazing applications sometimes I'm Blown Away by what you all build and how what you manage to pull off with net um you see health checks poly grpc y all of this amazing stuff but uh next slide when we still knew we hated to do more like even with all of those capabilities that we were building up then um then we still had quotes like these which you might have seen briefly in the keynote we still have people saying it's kind of overwhelming the amount of choice is really large and not even that's not necessarily bad but the paved path is really kind of obscure I don't know if these pieces are all supposed to go together it kind of keeps me up at night not that the package is bad that I've chosen or the path that I've chosen but is this bit supposed to go with that bit were they not designed to work together how am I supposed to figure this out and then there is also just an overwhelming amount that developers now need to know we're being asked to do more and more and more with less and less as time goes on and that also becomes overwhelming you now feel like you're asked to be an expert in things that you never had to be an expert in and then the last one which I think has probably been true since the beginning of time but is also far worse in the modern world is just nothing seems to work together by default and so we started this journey um after getting a lot of those quotes and think here with all that in mind over at the beginning of net 8 we were doing kind of a tour we were looking at okay well what is everybody at Microsoft who are building Cloud native applications doing what do they need and that largely fell into two broad categories we saw a lot of libraries that were filling gaps just the bits and pieces like log redaction and things like that right you'll see a lot of those libraries appear as part of net 8 as packages the Independent to Aspire but as but the part of the whole because they are about filling gaps that we noticed that people were were needed to needed to write and then the other which is more related to Aspire were these rapper libraries they would take a dependency and then kind of configure it for Telemetry shim it into their like a systems put retry policies around it um integrate it with and then make sure you could integrate with Di they became kind of the core of what components eventually became which we're going to talk about later on and then we also did some experimentation so uh for those of you who tried Tha and Tha was an experiment that myself Fowler um Ryan Noak a few other people worked on a while ago where a lot of the same Concepts that you see in a Spire appeared in it had a dashboard developer dashboard but it wasn't exactly the same it was yaml based it ran gave you the option to run as containers or not in Dev and it had a whole deployment experience built into it whereas a Spire doesn't tackle any of that deployment part because it was a part that didn't resonate from the experiment so we took lots of Lessons Learned as building that and all of you who have used Tai thank you thank you thank you a like they they your all of your feedback all the survey responses you did the bugs you logged and the and the discussions you had with us went a long way to helping us build what now is Aspire next and but even with all of that stuff even with Tai with all of these things distributed applications are just fundamentally hard still it was very difficult to um it's very difficult to get started to figure out what to do and so we built a Spire so but to to give you an example of this how do I get my front end to talk to my API like what is the port what is the URL how do I run all the projects locally um how do I get the end to end to work what it's about monitoring what should I use for for monitoring should I be scraping should I be using open Telemetry like what does APM even mean I don't know like how do I run redus do I need to install reders do I need to install SQL Server should I use containers should I not use containers how do I know what config options I need to set up how is should I be using environment variables should I be using KEYT should I be using local config files like how do I know that all these libraries are supposed to work together uh how what is the right resiliency policy should I be doing exponential back off should I not be doing that I don't know is the thing that I'm depending upon doing retries I don't really know the answer to that e that let me go and spend four months researching I hate it here like it is super hard to get started and try and build an application like this and just answering all of these questions which are all important and all very very um very difficult as you as you start let alone thinking about where am I going to deploy at which of the platforms am I going to use am I like all of that and that is even before you get to the reason you're actually getting paid to solve somebody's business problems it's amazing where we've landed up so our solution to a lot of these questions a lot of these problems is Aspire a stack for building observant observable resilient configurable Cloud native applications with done that we include a curated set of components so those libraries we talked about earlier those kind of shim libraries things that are configured by default for the environment we know you're going into they give you health checks they give you config that give you resilience there's a cool schematized config story that I don't think any of you have seen yet that we're going to show you later on today um and how can we make it easy for you to discover acquire and configure all those dependencies and then support you through the life cycle of your application from the getting started phase into production monitoring and diagnosing problems evolving your application through the whole inner and outer loop of your Dev cycle that is what we're trying to do we're F develop focusing on developer first developer productivity and in a loop stuff and integrating as naturally as possible with all the Ops tools that you need to use or whatever you want to use to get into production today and so without I guess that is my spill at the beginning that is where we came from that is the history and how we got here and some of the problems and now I believe over to you for demos for demos which is most of the rest of the talk all right so I am low on sleep and high on coffee so excellent nothing is going to go wrong we going to this is going to be amazing live demos and the demo we so aspires has been what the team has been working on or a subset of the team has been working on for at least I want to say like six months and we kind of like started from where Glenn spoke about but one of the big things we wanted to do was to make sure that we were on the right path so as we built a Spire we actually used it to build eShop yeah so it was used as you know to prove that the actual you know uh platform was working well was it was acting well it was amazing the bugs and inefficiencies we found just from like using a Spire to build up our just the demo app right like that eShop architecture diagram that I believe you saw at the beginning of the keynote um when you run that and then you see a thousand requests going to a database and you're like that doesn't seem like the most optimal way of doing this thing and it made it very visible um and that was part of our kind of proof that this thing this thing was was real is it it gave us confidence yeah it gave us a lot of confidence all right so I'm going to start a new project and I could do Aspire app in the brand new um vs 17.9 preview one you'll see if I type in Aspire there are two templates there's a net Aspire empty which has the orchestration appost and the service defaults project right then there's the start application which I also showed in the keynote if you didn't see it which has a Blazer front end a an API back end and a a cash for reddis yeah and I want to build up from from scratch to to show you how we got that Spire from um from if you want to kick off the tires and try a Spire jump into the starter applore if you want to create an app and then slowly build it up and add your stuff together and Stitch it together start with the either way works so I'm going to build a new Blazer front end application using the new blazer. net 8 that Dan just showed and all of his awesomeness yeah let's do blazzer front end three you see a checkbox right there this check box is brand new and list and Aspire orchestration right so this is if you were creating a Blazer starting with in this Cas but but then you could just start with I mean I have the web app I also want all the Aspire stuff immediately then I'm going to start adding more stuff in from the beginning so you can start empty you know at a Spire you can start you know with a Spire yeah all the options are are there for you so I'm going to minimize this and then just create a new project yeah all right new project very simple no magic one one one single project I'll build to make sure it works and isn't recorded so I can't like oh new get package with that's not great this is supposed to just work oh beded perfect we're going to ignore that and make sure it works going to run this unlike the keynote there's no fixing post we can't fix it in post H all right so we have home counter this is your typical Blazer app right and weather yep now weather is a local component if I look in my components Pages weather I'm getting weather for forecast you know in memory this is what you do yeah and it has a nice delay here to make ourselves look better when we fix the perf issue right for later on yes excellent I like it right so let's instead of having this be you know local let's pull the weather from a backand application MH so I'm going to add a new project still no Aspire no magic yeah look for API and I'm going to make web API yes not going to change the default we're not using controller today in Aspire here but we're not doing that deliberately in this demo flow but again in all of your there's a bunch of different ways to bring a Spire into an existing app or a new app right let's make the backend application now so now we have our first distributed system right front end back end and now I have to make it work so my front end wants to get weather from this weather forecast endpoint which is the same logic as on the front end but in a backend API so we're making ourselves um we're getting paid more money to build the distri that runs in the cloud sure so the first thing I have to do is to change this local weather to call the backend API right so you need the URL backend right create a weather client yep weather API client let's call that this is using the typed client stuff that we've had for a little while it's one of our earlier like attempts to make doing HTTP to inv environment better yeah you saw that look at that oh magic beauti all right let's take in the HB client primary con instructors un let's do I don't think I have cop turned on actually it won't it won't help me this time doesn't make a weather forecast anymore I can't playp anymore but you know I can do I can copy and paste ah yes so I have the weather forecast class ha from here I'm going to take this navigate back to here make this class public I'm going to create an array weather forecast get look at that all right that's not that's not Co it's good enough yeah and that's what we want to do and we are going to make this D client. get from Jon async yep hopefully you all know what this this this is to get a Json payload from the backhand API yeah I think the endpoint was called weather forast was it oh that's the URL in the new API project by default right it's it's it's that it's that URL SL weather forecast to H the weather end point yes weather forecast that's copy and past just to make sure type of perfect yeah I'm going to await this and then show you some C magic oo so if it's null returns an empty instead perfect that's new a new language feature as well no error handling it's good it's good all right the code is almost perfect and now I have to wire up this client to the DI container so I'll go into program Cs and I will I guess we should explain on that last one it means if it returns yeah we should so this just says either return me uh the Jason this can be null yes and if it's null I want to fall back to empty array right and those are a shortcut for a collection that satisfies so you get you get a collection and later on if you were to change it to some other type of collection it would just work without you changing it for example which is which is Magic well this isn't list so I have change it to but I'll it but if you if you were to later on refactor to list you wouldn't have to change the square brackets it it still work which is the m the cool feature the last phase is I'll come in here and use the normal not a new feature um typed htttp client mhm add the weather weather HTP client I get back the HT HTTP client in the call back yeah and I have to set the bit address to something so this is where things start to get complex like where what is the URL of my backend how do I find the backend Local Host 5000 it's some random port and I have to go into my app settings and I have to find the weather API but then if you run properties but if you run it in a different spot it'll be a different the best part is I open this file and I think there are four eurl like staring at me yeah which one which one do I copy the one for is the one for like HP HPS yeah no idea so this is the first challenge when trying to build semicolon in it does that work I know it doesn't so the the the trick here is like maybe I want this one let's just pretend I want this one all right so that's fine and then when I deploy like what happens this doesn't work anymore so I have to know the address my back end right this is the kind of rabbit hole you end going as you're trying to figure stuff out exactly so now I'm going to go into configuration and create my own schema and say like WEA API so this seems like a lot of typing to do there seems like a lot of typing and you still not manag to like actually do the thing you set out to do right correct so this is kind of where Aspire kicks in yeah at least the first the first phase where it kicks in so I can go ah here and I can add it's not hair I think it's add solution maybe on a project not on a solution you're right it's add hair yeah because it adds the so what when you when you write click on a project you can add orchestrator support the reason it's a project and not a solution is because when you add the orchestration support it includes the project you right clicked on in the orchestrator code you more than I've always known more than you Dam it all right let's click on that and I'm going to it's going to add these two projects the app host and the service defaults yeah and I add that to my my solution and the visual studio tooling will light up some stuff out beautifully it's working stuff out and if I look in my program CS it has worked out that I want to add this single project to my orchestration right all right so now I have this this project that's going to be my launcher essentially it will orchestrate anything that has to run as part of my end to end distributed system right so let's teach it about our two apps the back end the API it's already got the Blazer app because you right click so now to tell it about the backend API exactly so I have the Blazer app let's call this let's give it a better name this is like front end yep and let's create uh a rep to the to the to the backend application yeah what's super nice about having this all in C is I get intell ass sense I get good tooling so I can do Builder dot add and I see there's container there's executable add AIT rabbit mq I don't have to go looking up container images where things come from I can kind of use the power of the type system yeah to discover things yeah so I can do add project and let's see what happens I'll do projects dot but I only see Blazer app 3 why is that so when I added Aspire orchestration I only added a single project yeah I could do the same here I mean I could I could just type but I'm lazy so I'll come to my backend and click on ADD Aspire orchestration support yep and it says it already exists so it won't recreate those two projects but it does do this for me nice it injects code because I didn't want to type it so good I could have typed that but you know to show tooling yes let's do this so I have front and back end MH should call it weather weather let's call it weather got her name yep I can copy and paste this because there's going to be more there's going to be more exactly so I have front end back end and I have my weather API one really cool thing I can do is I can capture a reference this is another advantage of project a language a programming language is you're just using things you're familiar with references and such so I capture an object an object reference from my ad project call yeah and I can just call with reference and give it the back end so I'm adding a reference to the backend project from the front end project right this is how you set up the relationships between your projects and then when youf five that depend that gives you config and stuff right correct and this lets me from my front end reference the URL from the of the back end weather noce and no Port because we take care of making that work for you and so that weather string there is whatever you called it in that previous project corre where to kind of let me just close some of my program cs's yep close all but this nice feature yeah and then I can open up the program CS here right if you had called that fella if you would called that that uh that line uh three there if you would call if you would put Fowler instead of weather then you you would you would put fer in the URL exactly so if it made this like yeah cool same thing goes here yeah right cool so this enables surf Discovery to work on from the front end to the back end Project M so the last piece is just consuming this service in the weather um component so I can uh inject weather API client weather let's call this weather client yeah and I can get rid of my sleep to get paid more money whenever look at that improved perance by man not having copet feels so difficult get rid of this thing all right we should be good know I'm going to build first yeah now it looks amazing because we moved all the complexity to a different project which is what we do to a different team so Glenn's team owns the backand I don't care anymore about what back does I have deferred responsibility to Glenn's team for the weather API if it's done it's your fault now we're doing microservices mic this how it works okay it blame yeah so okay let's run this to make sure it works yeah I am starting the apphost project mhm so normally in vs I would have to go to solution click on properties check multiple startup projects and figure out how to add multip and it wouldn't give me the the the feature of being able to reference the backand just by name yeah so let me but when we added uh uh Aspire support we set just the Aspire apphost correct already so when you just run this now you get the Aspire demo that people have seen the dashboard and everything right of course yeah start kner for me ah nice even though I don't happen to using containers Docker is not required just so everyone knows Docker is only required if you do use containers from your aspire yeah apphost right vs is just being very nice to me and trying to to help me in the future because it knows I want to do yeah when you and in the starter application when you're doing file new there there is a check box that says do I want to use redus and then if you check that the starter app will actually already have a container reference it will then then require Docker but the experience itself doesn't require it unless you're you want to launch local containers um you don't have to have it there look at that so the app started I I get this dashboard and you can see the output says kind of two things no listening on this port this is the dashboard Port Y and it says this OTP server running at 164b being PLP being the open Telemetry open protocol well we'll talk about this later on but let's talk about the dashboard for now the front end crashed this is this is unplanned this is not part of the demo but let's actually try to dagn eror the error with the dashboard posting start failed why is that don't know buying a dress already in use that's not great why was it ready in use don't know let's try to figure out do you have a bunch of stuff you have logs and it's saying that 5226 is already in use let's see what port weather was running on wait what 5196 did we just get unlucky and choose like a port that's use I'm pretty certain that's what happened that's looks like what happened you got another something else running let's let's test this okay so the app fail to start let me attempt to go to my launch settings and just change this port to like I think it said that this one's in the use by default um Aspire will use your launch settings to choose the port you can choose random ports by default it tries to mimic whatever happens typically in AET in Loop style project this and this for those of you who don't know these ports are randomly generated when you create the project they don't Che so there could be something else using Port let's just make sure this is actually the case yeah um let me oh maybe I run it somewhere else first yeah oh it was that classic H okay let me let me just attempt to leave it alone Rel launch I think I killed the entire thing cool um also you should be able to rebuild individual projects without killing the entire dashboard to make it work yeah okay so it's working now yay no no errors ports Port Port ports Port conflicts are are terrible um I can launch the front end from right from the dashboard the dashboard shows me the URLs yep I can you just saw that you can see errors yeah you have a small resolution so that they all can see it yeah it's used for debugging so I just tried to debug the error so the for the executables yeah I can hit the back end let's see if this is working yep so Glenn is doing his job his back end seems working yeah it's great if we look at the dashboard again look at the traces you'll see why I showed in the keynote where you get this ENT to end distributed Trace view you can also see in this view that I am definitely not asking anybody else what the weather is and I must be making it up because otherwise you would see weather doing an outgoing request to figure it out exactly and we can see from the trace view we see the incoming call to weather the weather endpoint yeah the weather page in the front end y this is a call being made I think by visual studio so you can see every single call because HTTP client in.net is instrumented at the core yes yeah you're about to see everything and then this is super useful when you're like why is this thing taking so long or why is this inefficient I can't figure it out we we actually found a bunch of bugs in different libraries just from looking at this Tru yeah we fought the shoes they were fixed it was why is that request being made what's this request two request that's strange that's the Bucking Blazer buing X yeah which is very easy bya the because of the view that you get makes it obvious right so this is the the outbound call you can see the the span and span is an open Telemetry concept concept um this is showing you all the attributes of of the span you can see the bom request you can see the port the the the HB client Call Etc um these are also structured like so you can filter based upon specific parts of this and you can see all the logs that were part of this Trace so by default in espet core every request is tagged with an incoming span ID mhm and if you have you know a trace ID coming from like you know um a separate API call right you get to build this endtoend Trace across multiple Services yes and that happens without you having to have changed any part of your application even multiple languages because the standard protocol is standard so most languages have the ability for this to work for you yeah so we we we lean heavily on on open stand ERS to implement these these protocols so it isn't us building our own distributed tracing model this is just using raw OTP and open Telemetry as is and then just making everything around the an experience um clean so you can actually not have to worry about configuring stuff by default yeah all right so okay this is our end to end Trace we saw the front end have the the outbound call and then the weather forecast having a trace as part of that end to end and then the response coming back to the the front end yeah very cool nice logs so so let's look at some dashboard features since we're here yeah yeah might as well there's console logs so I can see all the logs from for my every service the front end or back end here I can see the the you know all the actual outbound calls I can even go into my app and dynamically change let's change the backend because the back end isn't logging much let's change the backend I think we're in development let's change the backend logs to be information oh my God intelligence oh my gosh yeah if I hit this request again from the front end to the back end mhm I should get more logs now well two other forecast Pages yeah if I go to traces you'll see this end to end Trace I should I should get way more no there is more than there was before right but not way more like you expected where are the weather forecast oh wait they change the wrong huh maybe the wrong service maybe I did this is the blaze isn't it it is yes ha okay same thing again but for the backend application the right one for real this time so the people in the audience could correct you I didn't recompile I just saved it refreshed you don't don't blow up on me what are you doing oh I changed wait it shouldn't don't blow up yeah this been this has been this has been an amazing example hold on hold on hold on that was the wrong Port maybe front end confused of which tab that was the wrong tab okay we're good we're still good we're still running all right let's close these still running I should have now more of an end to entry show including man you see all the logs so many yeah that seems like a horrible idea here's the back end okay so now now I have what have you done the trace yeah the back end view logs I can see weather yep front end you know the whole end ENT so front end two weather B to front end the response because the response yep all right nice these logs are structured so I can see the details of of every log I can see all the um proper added by individual um log calls I can extract different fields by adding filters so you get this kind of comprehensive view of being able to visualize your logs and traces right in development yeah I can also figure out what's going on like this thing is optimize for you to figure out what's broken yeah I think and and and one of the big things is I think this makes you appreciate Telemetry in the inner loop it's really hard to appreciate the fact that logs and metrics or traces are even working in development yeah gives you kind of like a really um visceral Loop feeling so you can see your traces you know look at properties and understand if what you're logging makes sense right in general yeah and you and you'll be familiar with them when you get the like production version of this because something broke there exact you know right um yeah you even get metrics so I can look at metrics for my Individual Services and you can look at all the metrics being sent from various parts of the runtime yeah the server chral um the whole thing layer and you can add your own as well yeah and we have these defaults kind of added a bunch of more metric in onet as well exactly yeah cool very cool next all right so let's move on to how some of this stuff works under the cover so we didn't spend a lot of time on service defaults in the keynote but this is one one of the places we want to get feedback from from customers that use Aspire right one of our challenges was how do we have defaults or strong opinions kind of weakly held in in Aspire projects how do we make open Telemetry work by default how do we make health checks work by default we want an experience where they're just there and they're kind of these crosscutting concerns shared across all projects at the same time we know that maybe in your company or your team you might have slightly different defaults that you have to conform to yeah so our opinions have to be there by default yet you know just slightly such that you can change them yeah we want you to we want to get you up and running with what we've observed and used as great like production defaults but we understand that they're defaults and different people's requirements are different sometimes you have to change them and the deeper we bake them in the harder it is to change and so there was this like this is this we thought was a really good middle ground where we give you the code in a shared project that you can reference easily by for everybody right um and you can tweak it and you can change it the problem the alternative would have been something like a config file and then the config scheme is starts to get very Lex stuff to get very difficult to manage you don't get any intell sense and things like that this is a final it it is more this is where we currently are in the first preview we definitely want to hear your feedback yeah indeed let's dive into the the app and kind of see what we exposed by default yeah so here's um this method called ad service defaults and any typical AET core.net worker app has these two patterns where you call add then you call use you know for for the the AET core Pipeline and to add services and configuration to di Etc so ad service defaults configures open Telemetry ads health checks ads service discovery which is a brand new component that we authored as part of aspire but isn't tied to Aspire one of our principles was if we have a generic component that isn't kind of tied to the Aspire end to end it will be um developed as a separate component but it will be part of the Aspire packaging the stack we call it a stack deliberately because it really is a lot of things put together that are all independently valuable and you could use bits and pieces of if you really wanted to and they're all authored and designed to be independent right um and and we just Aspire is just the thing that brings them all together and gives you a singular experience but none of them are very very tight most of them aren't very tightly coupled together but the experience of using them all together is kind of greater than the sum of all the parts is what we're trying to achieve really good point so we add service Discovery and here's a new method in net 8 that we added that lets you configure every single HTTP client Factory client that gets created so you can do cross cutting things like every single HB client that gets created is going to have this standard resilience package built on poly V8 yep and also I want to turn on surf Discovery yeah there's a good point there so let's talk a little bit about the resiliency stuff one of the things that happened over the course of donet 8 is we took a lot of the learnings that we had observed by people using poly at Microsoft and then we helped with the poly project and they did a new major version that is amazing and really fast if you haven't been watching what's happening in the poly project you should go check them out yeah the ADS stand resiliency Handler uses that and it just sets up a default policy that we think is good that you can then tweak and then you get it for free all the time so every HTTP request you make is going to retry it's going to handle transient faults properly it's going to be it's going to handle those like intermittent weird networking Glitches without you ever even knowing you might see a weird log where it's like this failed but then it immediately retried and you you never have to even worry about it which hopefully means far less getting woken up or panicking or having a bad outage because it kind of helps because it keeps you keeps your stuff up longer yeah and if you have like low trust for the team and our defaults yeah you can change them so even though this is our default you can come in here and you know put your own policy add your configuration put your own policies in modify our default policies change timeouts circuit breakers you know bulkheads yep so that that is all part of why this is part of your project and you know in your app itself yeah especially if you're already using poly and you already have a good standard policy that everybody understands you want to come and throw that in here and like switch it up accidentally on people yeah correct so this is this line is the magic that makes this code work weather what's happening is remember the process where we kind of we grab the URL from launch settings and we copy and pasted it into a configuration option yeah in here to make it work think of that same thing happening but behind the scenes we have this default schema so by default when you add service Discovery it adds these resolvers that know how to kind of grab um information from different places one of those places is configuration so you can actually use service Discovery without the Aspire host if you manually just use our default schema and say like Services weather and then this just put your all here whatever this is just like manually config this is effectively manually configuring service Discovery to get exctly specific so the system isn't coupled to a Spire but used with a Spire it kind of together works well right so even though so behind the scenes the magic isn't that magical it is what you would have done yourself if you were going to hard code a config you know for development and for production we're just making it easier for you so we're taking the things that you would have done on your own and making it more automatic right makes sense all right let's go a bit further here's our default open tary configuration now we expect this to get simpler over time because we're working with the team to figure out you know what things should be you know config based versus code based versus not so I expect this to evolve as we get through from preview one to the ga of of aspire indeed but by default we turn on tracing logging we wire up the open Telemetry logging provider so so so all I loger logs end up going through Hotel yep and then we also are metrics and we turn on default metrics for various things like you know the runtime counters this is part of the otel project we also add the built-in meters added to net 8 so as part of net 8 we added a lot of default metrics to HTP client aset core Kestrel and we had counters before like this isn't a Brand New Concept but meters lets you add Dimensions so it's a lot more powerful and you can build like really fancy dashboards that will'll show off um later in the week yeah I think Sam and Noah's talk on diagnostics we we'll dive into those details of what this are yeah all right let's keep going we add tracing so the the distributed Trace you saw the end to end tracing we have for aset core yep for inbound and for outbound we have grpc and H should be client by default and there's more stuff there's databases there's reddits there's caches when you pull in Aspire components as Glenn saided before those components bring in Telemetry as well by default right one of the core opinions is that this Telemetry system exists and everything that is participating in your whole solution should be feeding into it and so one of the requirements of an aspir for something to be an aspired component it has to fit into that world right and so if you use you know the Aspire redus client to talk to redus it is just the normal it's the same stack exchange redus client you would have used but we know we've configured it to integrate into this right it's configurating it to make sure it sends all of its data to the same endpoints it's making sure it also Hors the same resiliency policies it's making sure that it has a health check that lets allows us to check whether or not the redus database is up looks like visual studio just restarted because why not oh yeah okay um and then uh that that is part of what that is part of the opinions where we say opinionated is because we have we have that opinion that this dmetry system has to exist everything has to feed into it and everything that is part of that Aspire ecosystem should do that um and that's what that's how we that's how we that's how we cut up that's how we increase your ability to get started a lot faster because you can just take advantage you can just rely on that fact correct right and then you don't have to worry about it or think about it as much it just exists you can just you know you're you're good right so one of the main things that makes the dashboard the tracing metrics and structured logs view in the dashboard work is this this magic right here so OTP is the open Telemetry protocol yep and it's a standard protocol over either grpc or HTTP that lets applications send traces metrics and logs to some endpoint right I can egress that information from my app into some somewhere in development we inject this environment variable which is a standard open Telemetry environment variable ohel exporter LLP that's like super visible you zoom in a bit um yeah so this environment variable is is passed into into the application and the app then wires up the exporters so going from ilogger and meter and activity MH to the dashboard the dashboard in this case is your OTL server right it also means the same data is available with any any anything that understands OTP it's TI of us making sure you're part of that is it's pretty common in the cloud native world in the you have Prometheus grafana like there's this whole ecosystem of things that understand this protocol and we want to make sure that you're set up for that World by default even if you're and but also all the other like vendors um you know as I said Zer everything app insides like all the things are going to are just more and more supporting this world and we're setting you up for that exactly so I I think one of the really cool things about this this experience is we wanted it such that your code does not have to change in production using standard protocols using these like standard apis yeah this code can work whether you're in Dev against the dashboard since we imple implement the protocol as part of the dashboard when you go to you know app in sites or any other APM vendor to get like Diagnostics they support OT LP this same code doesn't change you just have to change what the Ser point they should integrate into whatever the Ops we also have commented lines to kind of help you get started with things like Prometheus which are very popular so if you want to expose a Prometheus script endpoint you can comment this yep and you add the package which is if you look at the there's a bunch of packages here there's one for there also one for Prometheus you would add that package Y and then we have this endpoint right here map PR map Prometheus scraping endpoint that you can uncomment and it will give you that kind of endtoend scrape flow out of the out of the box right yep there's where have my health check end points so you f it is the last piece is is health checks we have two health I asked on Twitter I think a month ago we we had a debate about what the health check name should be so so I asked on Twitter and we had this debate about should it be Health Z or health and I I chose we chose Health after a little bit of um debate and there's like different kinds of probes this pattern gives you a way to kind of Define health checks and fit into these two slots you can add more if you want to these are our default conventions for you know different kinds of probes yeah then as you move into your environment like kubernetes has support for probing these things and doing different things based upon whether you're healthy or alive or um they use Readiness and and such as the name for them but these are going to be useful these are mostly these aren't as useful in the dev environment but critical often in the production environment very very very cool so that was our kind of a default store mhm these two methods ad service default and map default endpoints these were automatically injected by the tooling when you right clicked and when I added Aspire orchestration so I didn't show that but this is to aspir ify the app you kind of add those two projects and you just call two methods yeah that kind of shows the this isn't that much magic you can kind of unpeel what happened I added this one call I added this second call yes so if you were if you have an existing set of apps that are all already working you want to make Aspire work by default add the appost add the Aspire orchestration you get our poost you get the shared code go and call those two shared code methods from each of the projects that you want to be part of it and then go and write the appst code if you're not using the tooling to do what black we just did in the thing and you get the same result and then you can also then slowly work things in and at that point even if you do nothing else you'll have already gained a massive amount of the thing even if you don't change your communication to you service Discovery or any of that stuff you'll still get a lot of the Telemetry you'll get a lot of you'll get a lot of benefits you probably even get the resiliency and stuff for free because you're still using H client so I'll show I'll show components and I'll dive into a little bit of a deep dive and show Dapper because Dapper came up a lot in on Twitter over the last like hour or so that is an aside well F switches gears there in the Aspire in the there is an Aspire samples repo in there we have an example of how to use Dapper we have an example of a node app participating in an Aspire project we have like a version of eShop in there that you can go play around with so you should go check all those samples out um to be able yeah to be able to see how how all this works and yeah there was a bunch of Interest with Dapper as after the keynote so you're watching us change our demo flow for you live yeah all right nothing could possibly break so let let me show a component so I'm going to go into my apphost and I'm going to Builder services in tell us my way to success yeah and I want to add a container for reddis so I don't know where that is but it tells me right add container for redis I'll call it cash two just to make sure that people know that I'm not just calling it cash and it's a magical name MH it's called Cash two and I'm going to cash from the front end if I can remember all the steps and if not Glenn will help me yep so I have now not just two projects but a container yeah so under the covers the there's an orchestrator that kind is running all these projects much like doer compose or any any any local orchestrator for those playing along at home fer has now spent I don't know 40 minutes to get to the point of what the app Aspire stter template provides for you out of the box but how much did you learn on the way there that is fair exactly I'm going to show another feature where I can right click on the project on the project on the project that's on the project this one M oh no this is the this is the back end I want the front end yep your front end what Fell's doing here is trying to add a redus cache and then configure the front end to use the redus to cach the output of my amazing API so that he doesn't have to call it as frequently because I'm constantly we trust you calling him and tell it so assume you want to find reddis on new get yeah let's try it so I'm going to type in Rus yep and I find it oh great it's the first one yeah I'm going to install this and I get the super awesome Stock Exchange Rus client and I don't get Telemetry I don't get uh config based configuration I I don't get a lot of things that are on my default right so I have to go look for reddis Y open Telemetry yep I kind of have to do this searching Game of like grabbing these four packages and then gluing them together to get this end to end experience like working I go through a bit of this in the blog post if you go check out the aspired blog post the steps that the redus Aspire package actually take care for you is probably eight or nine things by the time you've got the reddest client the open Telemetry bit the like resiliency bit and you've configured and wired all those up you're talking about multiple lines of code multiple package searches a bunch of research and once you've done it once or twice maybe it's fast but that first time you you will you you you basically won't do it the first what ver what version do you use like yeah so there's a whole set of things whenever you want to depend on one of these super common open-source client libraries to call some dependency um so there's this new feature called net you know add an fire component which which tries to give you a curat experience yeah these are just new get packages that come from just packages and there's a filter that we have trying to we're trying to provide we're trying to cut down on the noise if you're looking specifically for these but they are just under the covers n package and there's no magic like I can erase this filter and get the entire nugate so we aren't blocking you from using nugate in Aspire projects but this leads you to the to the Aspire Stock Exchange rather they actually want to want to be able to give you confidence that one that if you do these things they're going to integrate with all of that stuff we've just showed you point so I'm installing Aspire St exchange red output caching yeah output caching from new get live yeah nothing cashed uhuh as like 15 packages not 15 it's like yeah a bunch a bunch which is but that that is actually part of the point is like how you would not have found all those 15 packages probably not in the first not until after it fell over in production you didn't know why and you realized you needed to build a extra resiliency in front so now I have this Aspire Stock Exchange red Al caching package and I end up going to my program CS that gave me this method I'll bite yeah I key Redd add output cash yeah and I want to add Redd output cash yep and the name here maps to the name you put in the name I put in The Outpost that was shown in the keynote as well right so I call it cash two just to make sure people knew that it's cash two that it's cash two I'm cashing as well cashing too yeah all right this the magic here isn't too much magic the way this works is it looks for a connection string called cache 2 yeah so let's say you didn't have the Aspire Outpost running and you wanted to make the Aspire component work I could go into my app settings and going into connection strings cach two this is another example you could start using the um you could start using the components before you started using all the rest of it if if you just wanted to get their their features and the entire point is that we kind of we built the stack in a very decoupled way so you can actually consume components consume SE Discovery consume resilience any part of the stock independently so you can you can gradually adopt or you can grab the entire thing and have the experience work end to end that's why should if you can because it is amazing when it all makes it easier right so I can I I could do that but the aspire app post actually injects that schema in when I do with reference y so when I did this with reference in the in the host you'll see this Mega do comment that I wrote I'm proud of yeah it's pretty amazing that tells you it will inject the format connection strings source resource name in this case is cach two right underscore some value yeah that value just happens to be what it is in in development and in production it's something else right yeah you set that can that config to be something else all right let's see if I make this make this work now so I need I need to add so at this point there's nothing asiry about this um you're just adding the new app I SK this I could just pretend like this works you could we might as well we've got like five minutes you want to make some other points let okay perfect you should run it though to show the show the red should the yeah being added so we haven't actually turned on output caching here to actually have the Blazer like put the Val save the values into the cache and if unless F does that now but what happens now is when he runs the project next a Spire is going to run a container locally for you um that has redus in it it's going to set up all the connection strings and then when um and then if you go and modify your and then yeah if you put this out put cash attribute on this page then then then all of the framework is going to save the actual like HTML render for this page into redus and then the next time you come back for a request instead of executing all this code and generating it again just going to grab it from redus and what you'll be able to see is first of all Aspire in the dashboard you'll see this redus container exist and then when you go to the distributed Trace you'll be able to see that we check if the thing is there in redus if it's not we call the backend API and then the next time around we call redus and then we just return immediately and it's much faster that's the the flow here and I that you'll see in in a bunch of demos CU it's kind of the default it's also what the starter app is configured to do out of the box so if you just do file new starter app that's what it configured for to spin up redus do output caching and and save save all of that for you life demos the thing so disappeared before and the process is still running yeah I'm not sure what sort of State your machine is in the visual studio restarting is like not not normal that's not normal um let me just do one more thing and then show I think one more important part of this yeah entire thing let me kill the Blazer app mhm all right should be compiling now should be all fine Studio restarted but it left your app running this is a known issue we we're we're going to resolve it this fire yeah um this is life coding okay this is this is life coding and fun for you because we are normal developers that make mistakes sometimes yeah I know jeez okay all right front end backend projects and I also have a container running you can see my C is running I can see the image I can see the I also expect us to merge these three views at some point I think so but yeah at the moment they're all separate they're separate right now um but now the container exists the same as all the projects do and if you go hit the app a couple of times if I didn't break it let's see if I broke it or not yeah find you think it works uh you didn't help me so okay I mean it's works as good as anything could work without meating four oh it works perfect perfect nice so it cashed for 5 seconds didn't hit the didn't hit the back end API show me in the traces let's see so we hit you know front end only because it's cash cash okay that's the top here's where it starts right here so I hit the back end yep and then it's cashed so it should just actually let's look at this it hit the back end and then it cached the information in red yeah you can you can see how the reddis the reddis part of this thing is also included in your distribut chice yeah and by the way that was wired up by this one call so if I I'll just PE behind the scenes for like a slight second I F12 and it works like magic thank you visual studio if I add reddis this compon okay this component wires up a ton of stuff yeah ignore the the code specifics it is doing open Telemetry di resolution like health checks logging it's basically adapting Primitives of the underlying Library to work with those opinions that we talked about earlier yeah yeah one more thing I should show that glance spook Bel is a configuration schema yeah Aspire components can bring in schema and they sure part of our respect for what an aspired component does so we have this brand new feature where packages can bring in config schema fragments and they'll show up in intell sense live so I can you know get the config options for so what's happening here is the package is advertised all the things that you can configure and then you get completion in the config file just by adding the component yeah exactly yep and so then that should hopefully help you when you're trying to figure out how to configure a thing exactly makes it more discoverable yeah even in even in Jason instead of uh instead of code so got one minute I'll show the Manifest manifest yeah so one of the questions we get a bunch is is this thing a spound bound to Azure or CL or anything how you deploy it yeah well how do you deploy it and then also can I only deploy it to Azure cuz you seem to only ever a demo that and the Spire itself isn't actually tied to any Cloud any form um so let me do this thing where I can like find my project the way we support deployment is by not doing it yes um but but we do we do enough to support being able to spit out enough data for tools to consume for deployment right so this morning I demoed the Azure developer CLI deploying to to Azure the way that works and if you go to Scott Hunter talk at 4 he's going to show a deep dive on how ASD and Aspire work together mhm so I'm going to run this command net run and so the point here is that with Aspire we wanted to be able to express all of your developer need your app needs from a developer standpoint but not try and get into what your app needs in the like production environment we felt like that made it unnecessarily complicated and took it further away from the developer we wanted to be very developer first developer focused but make sure we gave all of those Ops tools what they needed to be able to participate in this world we didn't want to reinvent everything um this is like the best life demo ever so yeah so what Aspire does is generate a file which is what that command does that manifest.json which Expresses in a format that can be understood by another tool everything that a Spire knows about your app so here are all the resources cache two that we Define type is reddis weather it's a project and it has all the environment variables the bindings Etc this is what other tools use to glean provision like figure out what to do with this app app model Co and we are like I don't know a few seconds over time so thank you everybody there's so much more to show there is we didn't yeah there is lots more to show but there there's lots more previews too I think a question time now right yeah we are question time so someone maybe someone will ask a question that'll let them show what you want true
Info
Channel: dotnet
Views: 26,941
Rating: undefined out of 5
Keywords: .NET
Id: z1M-7Bms1Jg
Channel Id: undefined
Length: 55min 45sec (3345 seconds)
Published: Wed Nov 15 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.