What Is .NET Aspire? The Insane Future of .NET!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everybody I'm Nick and in this video I'm going to introduce you to what I believe is the most exciting thing announced in net H netcon and that is net Aspire now net Aspire is a bit unique because it wasn't actually developed in the public alongside the rest of net but for the past 6 months or so it is something that Microsoft has been doing in private and they just announced it to the public however I did have private access to it for a month or so before it's release and had enough time to let it so ke play around with it see what it can cannot do and in this video I'm going to bring everything together and just introduce you to the tech but I have way way more videos coming to show you what cool things you can do with this amazing Tech if you like of content and you want to see more make sure you subscribe for more training check out my courses on do tr.com okay so what is do net Aspire well let's see what Microsoft is saying it is an opinionated cloud ready stack for building observable production ready distributed applications and this is very much something for distributed apps and Cloud native apps it's not something that everybody absolutely will use but if you're building distributed apps this will solve a lot of your pain points and problems in fact as I'm going to be showcasing Aspire you might be reminded of another thing that rings a bell which might be project Thai now project Thai was an experiment from Microsoft and a lot of the learnings of that project came into DED Aspire you can think of aspire as a super set over time but without any of the deployment stuff now the biggest issue we have when we do distribute applications is we have many small apps and chunks and we want to get them all to talk to each other both when we build them locally on the developer environment but also when we deploy them Aspire aims to solve all that you can have a large number of services and it shouldn't be a pain point to get this database to talk to this thing or this app to talk to this cache or this everything should be very very easy to implement and get together I'm going to show you a very simple example that actually Microsoft has also showcased but aim to do a better and more honest and not so sales spey job explaining it I think the best way to understand Aspire is by actually showing you how we can use it so let's go straight into that that now before that real quick I'd like to let you know that our Black Friday discount on doet tr.com is now live you have until the 27th of November to use discount code Black Friday 23 to get 40% off any of the courses and 20% off any of the already discounted bundles so this is your once a year opportunity to invest in your learning and learn anything you need to thrive as a doet developer from unit testing integration testing we have clean architecture DDD check out our courses link down below use Code Black Friday 2023 and two things our EF core is not included because it just launched so that just gets 20% and the code will only last for 500 patches per cost so you might want to hurry this discount has actually been in Early Access for some days now to my patreons and our mail list so make sure you subscribe to our mail list as well if you're going to get these early accesses to discount codes now back to the video okay so let me see what I have here I have two applications I have a weather app web which is a Blazer application and then I have a weather app API if I just quickly run the API to show you what this is and then run the Blazer app as well just to give you an idea of how it all comes together here I have my weather app it's your bog standard weather forecast app nothing fancy here just gives five random weathers by default and then what I can also do is I can run this web project this Blazer web project and this project is just a default template project that has been configured to actually talk to that API to get that weather so when I go to weather here everything you see here is coming from that API and I can actually quickly prove that over here because I can go to the API I can decrease the information log level and if I save and I go and I call it a few more times then you can see all those requests going to the API and not staying in the Blazer app now let's take a quick look at how all this comes together what I have here is a weather API client that knows how to call that endpoint and return that weather forecast model and then in my pages I have the weather and at the bottom I'm using that client by injecting it from over here to get the weather and then display it and and that is it now if I go into program.cs that's how my client is configured so I have one dependency to that other API and had to somehow point to where that API lives now maybe you don't use this approach maybe you want to move this Base address to your app settings so you could have for example over here weather API Base address and you could load that property from here that is besides the point that doesn't change with Aspire I'll just leave it as it is here to make everything come together nicely but know that this could be something you load from app settings and you could have one app settings for development for production for staging and so on now when you have Services coming together especially in a local environment it is very hard to know where everything is running so I had to go here and be like okay there's this profile over here which has the HTTP version but if I want https then I have two options and one of them is this and one of them is this and then IIs and like you have so much going on in here that yes you maybe can nail everything down the first time but then as things change they can get out of sync they can break so Aspire aims to solve all that how well by changing the way these apps are running together as a system because remember when I want to debug my system as a system here I have to debug the API debug the web run them at the same time and then make sure everything is connected ready healthy resilient and so on so let's bring in aspire to see what problem it is solving now one thing I want to mention before I move on is that I will be using visual studio to inst install Aspire and show you how you can create an Aspire project however you don't need to you can actually do everything I'm going to do from Visual Studio through the CLI and Rider by the way will get support for Aspire as well the way to install Aspire without Visual Studio is to just do a a net workload update to update your net workload and then do a net workload install Aspire and this will install the Aspire workload on your machine and you will be able to then do net new Aspire and that will create an Aspire project now in Visual Studio you're going to have to to modify your installation and you're going to have to choose Aspire SDK which is in preview by the way over here to install the necessary templates and so on so let's jump in visual studio and go ahead on the solution and say that I want to add a new project and I'm going to search for Aspire now Aspire is a project type you can get a starter application which installs a few things by default which is actually what I'm showing you here but I want to show you the process so what I'm going to do is I'm going to say net aspire application over here and say next and then give it a name I'm going to say that this is the weather app. Aspire and it's going to leave there create a new folder then next and then I'm going to use net 8 and say create Now by default we're going to get two projects this apphost project which is going to be used to run our distributed system the two applications we have and then the service defaults which have this single extension. CS class over here which configures a lot of the defaults for how Aspire will operate which everything in there you can change by the way now let's take a look at the Aspire host over here as you can see we don't have the web application anymore we have the distributed application if you see the type of the project this is just an SDK normal microsoft. net. SDK project but it uses Aspire hosting and is Aspire host true which makes it the Aspire project type that it is now I can if I want to work with this in a manual way so I can start working with Aspire and implementing the configuration for the app host manually on how to run my apps but I won't do that what I'm going to do instead is I'm going to use the vs tool Ling which is pretty cool actually and I can't wait for ryer to also have it to add the SP support to my applications so first what I'm going to do is I'm going to go to the web project the Blazer app and I'm going to say right click add Aspire orchestrator support and it's going to say that hey we already have orchestration because you already have this project so I'm going to use this apphost project and the service defaults to configure everything by default for you and I'm going to say yes please do that for me the moment I do that if we go back to the apphost what happened is now we have this weather app ad project so the apphost is aware that I want to run some web project and that exists in this Project's namespace dot whether app Aspire or whether app defaults the moment you add a reference to this apphost it will show here as a project this is not the only thing that changed by the way in my program.cs in my web app we now also have this ad service default call which will add all the service defaults from that service defaults project so this is the extension method that is going to be called and there plenty of things here we're going to take a look at them in a second but also all the way to the bottom we have this map default endpoints some endpoints needed for aspire to just orchestrate everything and function and that is it now I will do the same for the API itself so I'm what I'm going to do again is right click on the API and say add net Aspire orchestrator support and as you're going to see now this this will also get a reference to the API so sorry this would actually be the front end and this should be the weather API and now I have both my projects here added and not only that my API itself also have the service defaults and so on now I won't need any more of the vs tooling and all that could actually be done manually by you if you wanted to so I'm going to go back to Ryder now so as you can see all that still works on ryer nothing is vs specific they made it in a way where the ID tooling is just complimentary and everything is driven by references and yugg packages now what I want to do is I want to get actually a reference to the API project because I can I can say our API equals this and then I can go to my front end and I can say with reference to the API and that will help with the wiring up of the web project being aware that the API exists and now with all that wired up what I want to do is I want to go back to the web project and I want to say that hey I actually don't need need to refer to this now by its address what I can do is I can say that hey this is just the weather API and that name matches the name over here so you can move this to a con if you want and then reuse it across everything so you don't have magic strings and so on I would recommend that but now you can actually refer to things as they are named in the apphost and you don't have to know exactly where they live on what address they're running on they will just work and all that Magic by the way is not that much magic as you think it all steps on the configuration framework environment variables and so on so with that what I can do now is I can just say hey just run the app host so I'm running this Aspire project over here not the individual apps but the app host which knows how to run my whole distributed application distributed system and when I do that what I get is this the Aspire dashboard so here I can see my front end and my API I can run them if I want once I can say go to the end points and I can see the app this all still returns as it should and as you're going to see I can also run the weather API if I want to and as you're going to see I have some great things here first I can see environment variables so all these environment variables are loaded from the framework many of them are open Telemetry ones some of them are logging and so on you can customize and inject your own then we can see logs so I can s to the front end and see the real time logs of those applications and over here the console itself and I can actually even go here and see containers we're going to see that in a second executables and also structured logs so for request I can go here and say view the details of this log and I can see span details everything then you can do things like filtering as well so message contains filter here filter by app and so on it is so so cool and not only that you can go into traces because all of that by default is instrumented with open Telemetry which is an open standard so any type of of app that supports the standard will work and I can go here and see for example this first weather request I can say View and I can see oh the API request took 74 milliseconds but then the HTTP get request for the front end took 200 and so on and I can go and here and click the individual Trace see how much everything took it's so so good that you get this by default you can even go to metric so you can select a service let's say the weather API and then you have the last 5 10 minutes 15 whatever an hour and you can see things like jit compilation time or the size of the objects on the garbage collector over time you can see things like the methods compile count and so on so as your app is being used you can see all this observability and tracking and you didn't have to manually change any of that yourself it is just there and it is customizable but it's using open and latest standards to have implemented now let's say I want to go a step further and I want to add output caching to that weather view because the weather is not likely it's going to change within a 5c Gap so let's say I want to cash that page for 5 seconds but I don't want to do that with an inmemory cach because remember I'm building a distributed application so for that reason I'm going to use reddish cash and I'm going to run it in a container so what I can do is I can actually go to the ab host and I can say just by default that hey I want a cach over here it's going to be build do add redis container which they add by default because they know reddis is a standard for distributed caching so they add support for it by default and I'm going to say R is cash over here and now I have the cash and that cash will go to the project so I'm going to say with reference to that cache which means I can now go to the web project and go to new get packages and sets for Aspire do RIS and I'm going to use this output caching reddish package over here these are Microsoft maintained aspired packages that bring all the things you need with the best practices by default together and they just give you an extension method to wire up and use so I'll go here and just say add the output cashing one and now I will go to the program.cs and say builder. add RIS output cache I'm going to of course give it a connection string name which here as you can imagine it is actually the name of the Aspire defined container so I'm going to move here just paste this over here configure nothing else I could if I want to but don't want to I don't need to and then I go all the way down and after the map end points I'm going to say use output cache and then I will go and introduce the caching to the page so go to the weather and say attribute output cache which is a net8 thing then I'm going to say duration is 5 seconds so this page will be cashed for 5 seconds on red now I want to point out I'm not running any container in Docker I just said add a container and now all I'm going to do is say run the app host and now as this is running as you're going to see not only the apps will start but a Docker container for redish will also start and you can see it over here this reddish container using the latest reddish version which by the way you can override if you want it is now running and here in my dashboard I no longer just have the front end and the weather up but in containers I also have the redish cash and by the way I can see them consolidating these three views to a single one because it doesn't really make sense to have them separate but now if I go to the front and say go to weather as you're going to see the weather is cast for 1 2 3 4 5 seconds and now if I click again it's going to be new weather cash for 5 seconds and all that cashing is happening in redis so if I go to Aspire and I can actually prove this with traces which I now have you'll see that the first request over here goes to the weather a API but all the next ones within 5 Seconds don't that's why you do have the weather forecast call to the API and also a set X to set the reddish value in the redish container so you have the full observability stack over here including containers and reddits and everything by default because there is instrumentation in aspir packages or how they call them components but I can also prove that hey there's no request going to the weather API and it all goes to redish because now I can see that there's a red get happening over here and it's happening really really fast as you can see over here it is incredibly cool we're getting so much out of the box just by default and you can customize everything you're seeing if you're excited for this and you want to see more please subscribe because I have way way more content for Aspire the last thing I want to show you as part of this showcase is actually how you would deploy an application like this and Microsoft did the very smart thing of not dealing with it Ty one of the biggest criticisms was that he was trying to deal with deployment and that was very tricky because everyone has a different way of deploying well in Aspire Microsoft said we're going to give you a way to consume how your app comes together but we're not going to tell you how you will deploy it we won't deal at all with that the way they do that is as follows I'm going to go and CD into the apphost over here and I'm going to say netrun publisher and the publisher I want to run is the Manifest and I want the output path to be just manifest.json here we go so this will now run What's called the Manifest publisher to generate a manifest.json file over here which then describes how everything comes together in my application from resources as you can see I'm using a Redd cach I'm using the weather API of type project the path is here in case you want to point to the Cs Pro to get that in order to deploy and build and so on you have open elemetry configuration as environment variables you have bindings you have schemes you have your front end you have everything defined over here including the HTTP whether API whether bindings which are just environment valuables which you can override if you want to so it's magic but it's a very high level magic you can actually tap into and change in any way you want I think the project is insanely amazing there's tons of things I haven't showed you and I will show you so please do subscribe to see more and I can't wait to see how far Microsoft can take this because I think there's a bright future ahead of us for us building distributed applications but now I want to know from you what do you think about this project leave a comment down below and let me know well that's all I had for you for this video thank you very much for watching and as always keep coding
Info
Channel: Nick Chapsas
Views: 245,276
Rating: undefined out of 5
Keywords: Elfocrash, elfo, coding, .netcore, dot net, core, C#, how to code, tutorial, development, software engineering, microsoft, microsoft mvp, .net core, nick chapsas, chapsas, dotnet, .net, c# new features, c#, .net new features, .net core new features, .net 8 features, c# 12, c# .net 8 features, .net aspire, what is .net aspire, dotnet aspire, cloud native, cloud-native, distributed apps, .net 8 aspire
Id: DORZA_S7f9w
Channel Id: undefined
Length: 18min 35sec (1115 seconds)
Published: Sun Nov 19 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.