What is .NET Aspire? Why do you NEED it in every .NET app? How to get started in minutes!

00:22:02
https://www.youtube.com/watch?v=fN3ufsIF7vs

摘要

TLDRThe video showcases .NET Aspire, a powerful tool for building cloud-native, observable, and resilient distributed applications. It guides viewers through the process of integrating .NET Aspire into existing .NET applications, including backend services and frontend Blazor components. Key features such as service discovery, telemetry, and the addition of Redis and PostgreSQL for caching and database management are highlighted. The presenter demonstrates how to easily configure these components and deploy applications using Docker and Azure, emphasizing the simplicity and efficiency of .NET Aspire in modern application development.

心得

  • 🚀 .NET Aspire enables cloud-native application development.
  • 🔍 It provides built-in telemetry for monitoring performance.
  • 🔗 Service discovery is simplified with automatic configurations.
  • 🛠️ Easily integrate Redis and PostgreSQL for caching and database management.
  • 📦 Deployment can be done using Docker and Azure services.
  • 💻 Visual Studio supports direct publishing of applications.
  • 📊 Structured logs enhance debugging and monitoring capabilities.
  • 🔄 Existing .NET applications can be easily upgraded with .NET Aspire.
  • 📚 Comprehensive documentation is available for developers.
  • 💡 Custom configurations are supported to meet specific needs.

时间轴

  • 00:00:00 - 00:05:00

    The video introduces .NET Aspire, a technology for building cloud-native, observable, and resilient distributed applications. It highlights the need for service discovery and telemetry in existing .NET applications, including Blazor frontends and APIs. The presenter demonstrates how to integrate .NET Aspire into existing applications with just a few clicks, enabling enhanced observability and resilience.

  • 00:05:00 - 00:10:00

    The presenter showcases a sample shop application with a backend using minimal APIs and Entity Framework. The application includes a product endpoint and a Blazor frontend. The video explains how to set up multiple projects in Visual Studio for debugging and how .NET Aspire simplifies service discovery and debugging across projects, eliminating hardcoded strings.

  • 00:10:00 - 00:15:00

    The video continues with the integration of .NET Aspire into the backend project, creating new projects for app hosting and service defaults. It explains the purpose of these projects and how they facilitate service discovery, telemetry, and health checks. The presenter demonstrates running the application and accessing the .NET Aspire dashboard, which provides insights into active requests and logs.

  • 00:15:00 - 00:22:02

    The presenter configures the frontend project to communicate with the backend, emphasizing the importance of service discovery IDs. The video also covers adding caching and PostgreSQL support to the application using .NET Aspire, showcasing how it simplifies the process of integrating various services and managing containers with Docker. Finally, the video discusses deploying the application to cloud backends, highlighting the ease of use of .NET Aspire.

显示更多

思维导图

视频问答

  • What is .NET Aspire?

    .NET Aspire is a technology for building cloud-native, observable, and resilient distributed applications.

  • How can I integrate .NET Aspire into existing applications?

    You can integrate .NET Aspire into existing applications by adding orchestrator support and configuring service discovery.

  • What features does .NET Aspire provide?

    .NET Aspire provides features like telemetry, service discovery, and easy integration with various services like Redis and PostgreSQL.

  • Can I use .NET Aspire with Blazor applications?

    Yes, .NET Aspire can be integrated with Blazor applications for frontend development.

  • How does .NET Aspire handle service discovery?

    .NET Aspire simplifies service discovery by automatically managing service references and configurations.

  • What is the benefit of using telemetry with .NET Aspire?

    Telemetry provides insights into application performance, including metrics and logs for monitoring.

  • How do I deploy applications built with .NET Aspire?

    Applications can be deployed using Docker and Azure container services, with direct publishing options available in Visual Studio.

  • What types of databases can I use with .NET Aspire?

    You can use various databases, including Redis and PostgreSQL, with .NET Aspire.

  • Is there documentation available for .NET Aspire?

    Yes, there is comprehensive documentation and tutorials available for .NET Aspire.

  • Can I customize the configurations in .NET Aspire?

    Yes, .NET Aspire allows for customization of configurations to suit your application's needs.

查看更多视频摘要

即时访问由人工智能支持的免费 YouTube 视频摘要!
字幕
en
自动滚动:
  • 00:00:00
    net Aspire is one of my favorite new
  • 00:00:02
    pieces of Technologies inside ofet
  • 00:00:04
    enabling you to build these Cloud native
  • 00:00:06
    observable production ready distributed
  • 00:00:08
    applications if you're like me you got
  • 00:00:10
    back ends you got front ends you got a
  • 00:00:12
    bunch of clients and you need your
  • 00:00:14
    applications to be resiliant observable
  • 00:00:17
    enh handsome with Telemetry and you need
  • 00:00:19
    that great service Discovery and that's
  • 00:00:21
    where donet Aspire comes in but if
  • 00:00:23
    you're like me you already have existing
  • 00:00:25
    donet applications you got Blazer front
  • 00:00:27
    ends you got MVC front ends you got apis
  • 00:00:30
    on the back ends you got mobile clients
  • 00:00:32
    you want to add net Aspire into those
  • 00:00:35
    existing ones and that's what I'm going
  • 00:00:36
    to show you today and just a few clicks
  • 00:00:39
    in just a few minutes you can enable
  • 00:00:41
    donet Aspire in any of your donet
  • 00:00:43
    applications so let's go ahead and take
  • 00:00:45
    a
  • 00:00:46
    [Music]
  • 00:00:54
    look so if we take a look at the project
  • 00:00:57
    it might be something very familiar to
  • 00:00:58
    you you have a back end here in this
  • 00:01:00
    case this is a shop application that has
  • 00:01:02
    a product endpoint backend so we can see
  • 00:01:04
    here it's using the minimal apis it has
  • 00:01:05
    a simple get to get all the products
  • 00:01:07
    coming back from the system this is
  • 00:01:09
    using enity framework and it's just
  • 00:01:10
    pulling in all the data here as well and
  • 00:01:12
    you can do posts and deletes and all
  • 00:01:13
    that good stuff as well which is nice
  • 00:01:15
    and there's also a front end over here
  • 00:01:17
    so we can see that if we go into the
  • 00:01:19
    components we have some layouts we have
  • 00:01:21
    a products page here so just standard
  • 00:01:23
    Blazer and razor syntax going on here
  • 00:01:26
    which is nice uh we can also note if I
  • 00:01:28
    zoom in over here that we have ser
  • 00:01:29
    services so we have a product service
  • 00:01:31
    that's going to communicate with that
  • 00:01:33
    backend that HTTP request if I go into
  • 00:01:35
    my app settings it's being controlled
  • 00:01:38
    here via the HTTP end points just on
  • 00:01:40
    Local Host so when you're developing
  • 00:01:42
    these types of applications you'd often
  • 00:01:44
    have to run multiple projects so in
  • 00:01:46
    Visual Studio you could go into your
  • 00:01:47
    properties you actually enable multi
  • 00:01:49
    project setup and you could then start
  • 00:01:52
    with both of these debugging at the same
  • 00:01:54
    time so it's a really nice powerful
  • 00:01:56
    feature of visual studio um but if we
  • 00:01:59
    have of projects uh inside of it this is
  • 00:02:02
    where Don and Aspire comes in to not
  • 00:02:04
    only get rid of these sort of nasty
  • 00:02:05
    hardcoded strings with service Discovery
  • 00:02:08
    but also enable us to debug multiple
  • 00:02:10
    projects while still getting tons of
  • 00:02:12
    insight into our project as well so uh
  • 00:02:15
    let's take a look at that the first
  • 00:02:17
    thing I want to do is go into products
  • 00:02:18
    this is just the back end it could be
  • 00:02:20
    any of the projects I have I'm going to
  • 00:02:22
    rightclick and if I go down to add we're
  • 00:02:25
    going to see an option here for donet
  • 00:02:27
    Aspire package but also donet aspire
  • 00:02:29
    orchest support and that's what we're
  • 00:02:30
    going to add we'll come back to the
  • 00:02:32
    package thing which is really cool in a
  • 00:02:33
    little bit so I'm just going to say add
  • 00:02:35
    orchestrator support it's going to take
  • 00:02:37
    a look at the project and understand
  • 00:02:39
    what's in it and then take a look at the
  • 00:02:41
    Aspire packages that I have and here we
  • 00:02:44
    can see that it says hey what do you
  • 00:02:45
    want to name the project that I'm going
  • 00:02:46
    to create uh where do you want me to put
  • 00:02:48
    it so we'll use the default folder and
  • 00:02:50
    then it's going to create two new
  • 00:02:52
    projects the apphost and service
  • 00:02:53
    defaults I'm going to hit okay here and
  • 00:02:56
    if we zoom in over here we're going to
  • 00:02:58
    see that it's created these two projects
  • 00:03:00
    we have the app host we have the service
  • 00:03:02
    defaults and we get this nice overview
  • 00:03:05
    page of getting started with net
  • 00:03:07
    Aspire uh awesome so cool so what is in
  • 00:03:10
    these projects well the app host you can
  • 00:03:12
    think of as the glue between the
  • 00:03:14
    projects that you have if we take a look
  • 00:03:16
    at the dependencies there's actually a
  • 00:03:17
    projects node and the products have been
  • 00:03:19
    added here automatically which is nice
  • 00:03:22
    additionally there's this app hosting uh
  • 00:03:25
    net Aspire noua package that is going to
  • 00:03:27
    be the app host that is the glue now
  • 00:03:29
    there's only one little program CS file
  • 00:03:32
    in here it's a distributed application
  • 00:03:35
    uh for donet Aspire and it's adding the
  • 00:03:38
    project via this Project's product it's
  • 00:03:40
    using some Source generators behind the
  • 00:03:42
    scenes to generate these things
  • 00:03:43
    automatically which is pretty awesome
  • 00:03:46
    now there's this other project with is a
  • 00:03:48
    service defaults and this one's actually
  • 00:03:49
    really really interesting if we take a
  • 00:03:51
    look at the Nate packages we can see
  • 00:03:53
    it's using HTTP uh resiliency service
  • 00:03:56
    Discovery open
  • 00:03:57
    Telemetry uh uh all the different ones
  • 00:04:00
    in here for aspnet core runtime and a
  • 00:04:01
    bunch more and we can see that it is a
  • 00:04:04
    net aspir share project that will be
  • 00:04:06
    shared across any project enrolled in
  • 00:04:08
    net Aspire so if we look at the
  • 00:04:10
    extensions. Cs we're going to notice
  • 00:04:12
    this really really important method here
  • 00:04:14
    add Ser as a defaults it takes in the
  • 00:04:16
    host application Builder it will
  • 00:04:18
    configure open Telemetry default health
  • 00:04:21
    checks service Discovery it will add in
  • 00:04:24
    standard resiliency a Handler right here
  • 00:04:28
    and Discovery service for the HTTP
  • 00:04:30
    client it will also then configure open
  • 00:04:33
    Telemetry with all the things that you
  • 00:04:34
    could possibly want by default and you
  • 00:04:36
    can of course modify this to your liking
  • 00:04:39
    and then it'll have open Telemetry
  • 00:04:40
    exporters so by default it has um one
  • 00:04:44
    built in if you have an uh open
  • 00:04:46
    Telemetry endpoint you can go ahead and
  • 00:04:48
    specify that there but you can also go
  • 00:04:50
    ahead and Export this to Prometheus or
  • 00:04:52
    you could export it to the Azure monitor
  • 00:04:55
    Service as well which is really cool and
  • 00:04:56
    there's a bunch of other stuff in here
  • 00:04:58
    so just health checks that are built in
  • 00:05:00
    default endpoint handling with the
  • 00:05:02
    health and Alive mapping in there
  • 00:05:04
    automatically for you so it handles it
  • 00:05:05
    all for you which is really really nice
  • 00:05:09
    so we have this project and it's here so
  • 00:05:11
    if we run this project what we're going
  • 00:05:14
    to see is that we're running the app
  • 00:05:16
    host we can see the app host here is
  • 00:05:19
    bolded because that became our startup
  • 00:05:21
    project and we can see once I bring this
  • 00:05:24
    over that the app host is started up
  • 00:05:26
    here uh using uh the net Aspire or
  • 00:05:29
    registration process and then what it's
  • 00:05:31
    going to do is launch here we go awesome
  • 00:05:35
    our net Aspire dashboard as my name of
  • 00:05:38
    the project eShop light and we can go
  • 00:05:40
    ahead and change this over here to dark
  • 00:05:42
    there we go and this is beautiful it's
  • 00:05:44
    using the the fluent UI package uh for
  • 00:05:46
    Blazer which is awesome it's an awesome
  • 00:05:48
    Blazer app so what do we get here well
  • 00:05:50
    first and foremost we can see that we
  • 00:05:52
    have a project of products it's running
  • 00:05:54
    I have two end points I have an https
  • 00:05:56
    and an HTTP I can click on that it's
  • 00:05:59
    going to go and hit that endpoint so we
  • 00:06:01
    can see all the products coming back we
  • 00:06:03
    can then view logs for example we can
  • 00:06:06
    see the raw logs that are coming in I
  • 00:06:08
    love structured logs to be honest with
  • 00:06:09
    you so here's all the things that are
  • 00:06:11
    coming in and we can see there's
  • 00:06:13
    actually a stack Trace here um in this
  • 00:06:15
    beautiful view which is saying like the
  • 00:06:16
    browser hit product so it's not super
  • 00:06:18
    interesting right now because we just
  • 00:06:19
    have one endpoint but it's here we also
  • 00:06:21
    get these metrics though and this is all
  • 00:06:23
    coming from that open Telemetry so we
  • 00:06:25
    can see the active requests coming in
  • 00:06:27
    for example here the duration we can see
  • 00:06:30
    the match attempts connections TLS
  • 00:06:32
    handshakes requests that are cued you
  • 00:06:35
    know there's not too much Happening Here
  • 00:06:36
    ex I just hit that at once but we get
  • 00:06:38
    all these active requests and
  • 00:06:39
    connections and durations so this is
  • 00:06:41
    awesome with very little work at all if
  • 00:06:43
    I just have a backend I get this great
  • 00:06:46
    insight into my application that's off
  • 00:06:49
    and running which is pretty
  • 00:06:51
    astonishing okay so let's go ahead and
  • 00:06:53
    stop that and now let's go ahead and
  • 00:06:57
    configure our frontend project the store
  • 00:07:00
    to communicate with our backend that's
  • 00:07:01
    what we're going to need to do so we're
  • 00:07:03
    also going to rightclick and we're going
  • 00:07:04
    to add and we're going to add net Aspire
  • 00:07:07
    orchestrator support and now Visual
  • 00:07:09
    Studio is saying hey this project
  • 00:07:10
    already exists and it needs to update it
  • 00:07:13
    to add the store orchestrator in there
  • 00:07:17
    all right cool so now we can see that
  • 00:07:18
    the Project's been added automatically
  • 00:07:20
    which is kind of cool that just updated
  • 00:07:22
    right there if I look at the
  • 00:07:23
    dependencies we'll see that there's
  • 00:07:24
    multiple uh projects here and if we take
  • 00:07:27
    a look first and foremost in that
  • 00:07:30
    products um over here the one that we
  • 00:07:32
    were just running we can see that this
  • 00:07:34
    ad service default was added because a
  • 00:07:37
    reference over here to that project was
  • 00:07:40
    added so that's how that was configured
  • 00:07:41
    automatically for so just that one line
  • 00:07:43
    of code was
  • 00:07:44
    injected now based on the version that
  • 00:07:46
    you have it should automatically inject
  • 00:07:48
    it I'm running hot bits over here uh so
  • 00:07:51
    uh I'm just going to go ahead and add
  • 00:07:52
    this automatically um I'm going to go
  • 00:07:54
    ahead and drag and drop this store so
  • 00:07:56
    there's I'm running preview five right
  • 00:07:58
    now of aspire preview 3 of Visual Studio
  • 00:08:00
    2022 1710 uh so this should all be fixed
  • 00:08:03
    up that should automatically configure
  • 00:08:05
    everything for you and those lines of
  • 00:08:06
    code should be added for you in this
  • 00:08:08
    instance right now there's a didn't do
  • 00:08:11
    it didn't do it for me because it's
  • 00:08:12
    still in preview but that's all you need
  • 00:08:15
    to do is say add service defaults and
  • 00:08:17
    then all I did was I drag and dropped
  • 00:08:18
    service defaults onto store which then
  • 00:08:20
    configured this project here so that's
  • 00:08:22
    all you need to do okay so the one thing
  • 00:08:26
    that I I didn't mention too much were
  • 00:08:27
    these IDs and these IDs be come very
  • 00:08:30
    important part of the service Discovery
  • 00:08:32
    so the products this ID is going to be
  • 00:08:35
    important when we're configuring how to
  • 00:08:37
    communicate to it in any other project
  • 00:08:41
    so we need to basically add a reference
  • 00:08:43
    and say hey store become aware of
  • 00:08:45
    products here and then enroll into the
  • 00:08:48
    service Discovery so I'm going to
  • 00:08:50
    actually say VAR products and I'm going
  • 00:08:52
    to set it equal to this because this ad
  • 00:08:54
    project returns an IR resource Builder
  • 00:08:56
    coming back to me which then I can use
  • 00:08:59
    somewhere else so on this project I can
  • 00:09:01
    say with reference and I say pre please
  • 00:09:04
    reference the
  • 00:09:05
    products and now D Aspire will know that
  • 00:09:09
    the store Front End would like to use
  • 00:09:12
    and um be aware of the product backend
  • 00:09:16
    and what that means is in service
  • 00:09:17
    Discovery we can use this ID so if I
  • 00:09:19
    open up that app settings again over
  • 00:09:21
    here we can go ahead and change this
  • 00:09:24
    HTTP or the https whatever we want to
  • 00:09:26
    use to automatically use product and
  • 00:09:29
    then D despire will handle all the
  • 00:09:32
    product endpoint orchestration for us
  • 00:09:34
    automatically and here we can see that
  • 00:09:36
    the HTTP Builder uh uh client that I'm
  • 00:09:39
    using here in the Builder service is
  • 00:09:42
    just calling that configuration file so
  • 00:09:44
    that's how it's going to pull it down
  • 00:09:45
    automatically so instead of having to
  • 00:09:46
    hardcode the string or worry about it
  • 00:09:48
    anywhere else this will automatically
  • 00:09:50
    handle it for me which is nice so in
  • 00:09:52
    this case I could get rid of this entire
  • 00:09:54
    configuration and it would you know just
  • 00:09:56
    hardcode that string in there if I
  • 00:09:57
    wanted to uh but this is nice that still
  • 00:09:59
    configurable there okay so now all I
  • 00:10:01
    need to do is run this project all right
  • 00:10:04
    so we have our service defaults in both
  • 00:10:06
    program CS here and another program CS
  • 00:10:10
    here we have the ad service defaults and
  • 00:10:12
    again our dashboard is going to launch
  • 00:10:15
    there we go so I'm going to put this
  • 00:10:17
    back in dark mode for us there we go
  • 00:10:18
    cool so now we'll see we not only have
  • 00:10:20
    our products over here we also have our
  • 00:10:24
    store front end so I can go ahead and
  • 00:10:25
    click on that and this is going to use
  • 00:10:29
    that backend service and I can prove it
  • 00:10:31
    to you so if I come down over here into
  • 00:10:33
    my products end points let's just go
  • 00:10:36
    ahead and add a breakpoint here there we
  • 00:10:38
    go so we're going to say get on that
  • 00:10:40
    product I'm going to go back over to my
  • 00:10:43
    browser and I'm going to go ahead and
  • 00:10:45
    refresh that and sure enough there it is
  • 00:10:47
    I go ahead and have it right there which
  • 00:10:49
    is really cool so there we go sitting
  • 00:10:50
    that back in all in real time so now
  • 00:10:52
    what we are able to get are more of
  • 00:10:55
    those logs so here's all the logs is
  • 00:10:57
    normal but again I love structured logs
  • 00:10:59
    so now we're going to have more
  • 00:11:00
    information we're going to have
  • 00:11:02
    information such as that store hitting
  • 00:11:04
    the product so for example now if I take
  • 00:11:07
    a look at uh one of these traces we can
  • 00:11:09
    see that we have the store in the
  • 00:11:11
    browser for the get going off calling
  • 00:11:13
    get of the products and coming back if I
  • 00:11:16
    just tap on the main traces this is a
  • 00:11:17
    pretty cool view too so if you have a
  • 00:11:18
    lot of different microservices
  • 00:11:20
    communicating together you're going to
  • 00:11:21
    see all of them coming in so we can see
  • 00:11:24
    all those requests the duration of those
  • 00:11:26
    requests and a lot more so again now I'm
  • 00:11:29
    able to look at the store look at those
  • 00:11:32
    active requests that are coming in all
  • 00:11:34
    in real time which is pretty neat so if
  • 00:11:36
    I refresh this we're going to see those
  • 00:11:38
    hits again and then we're going to see
  • 00:11:40
    back over here we're going to get more
  • 00:11:41
    requests uh active requests coming into
  • 00:11:44
    the server uh over here uh which is
  • 00:11:47
    really really nice now a few other
  • 00:11:49
    things to note over here is this details
  • 00:11:52
    U this is pretty nice when you tap on
  • 00:11:54
    this this has this nice slider and we're
  • 00:11:56
    going to see the resource the state of
  • 00:11:59
    it
  • 00:11:59
    we're going to see the project path
  • 00:12:01
    where it's coming from the process ID uh
  • 00:12:03
    all the endpoints but we're also going
  • 00:12:04
    to see all the environment variables
  • 00:12:06
    that doet Aspire set up for us
  • 00:12:08
    automatically so here we have like all
  • 00:12:10
    the different URLs that are coming in we
  • 00:12:12
    have the launch profile that's coming in
  • 00:12:14
    we get all of the open Telemetry thing
  • 00:12:15
    so this is all configured automatically
  • 00:12:17
    by default for us when we go ahead and
  • 00:12:19
    look at that the same can be set for the
  • 00:12:21
    store we might have a few different ones
  • 00:12:23
    since that's the Blazer application so
  • 00:12:26
    all of those environment variables are
  • 00:12:27
    still there so they're overridable later
  • 00:12:29
    on if you want so it's really nice to
  • 00:12:32
    see all of these come in to the
  • 00:12:36
    project okay so now we have our back end
  • 00:12:39
    communicating with our front end but
  • 00:12:41
    maybe we want to do more what if we
  • 00:12:43
    wanted to add I don't know caching into
  • 00:12:46
    this project what would you need to do
  • 00:12:47
    well you need to go figure out all the
  • 00:12:49
    packages that you need you need to
  • 00:12:51
    figure the endpoints you need to
  • 00:12:52
    download the containers and you need to
  • 00:12:54
    figure out everything for you well now
  • 00:12:56
    it's on an Aspire it handles all of that
  • 00:12:58
    automatically all you need to do is on
  • 00:12:59
    your app host is I'm going to go in and
  • 00:13:01
    I'm going to say add and I'm going to
  • 00:13:03
    say donet Aspire package you can do this
  • 00:13:05
    not only on the host but also on the
  • 00:13:08
    different clients or the different
  • 00:13:09
    projects that you've added so here I'm
  • 00:13:11
    going to say donet Aspire um package so
  • 00:13:14
    we can see the owner Aspire we get all
  • 00:13:16
    these different pre-releases here coming
  • 00:13:18
    in uh and I'm going to go ahead and add
  • 00:13:20
    the reddest one and here we go 8.0 prev5
  • 00:13:23
    is the one that I'm on uh here we go so
  • 00:13:25
    I'm just going to install
  • 00:13:26
    that cool so we can go ahead and add the
  • 00:13:28
    Redd hosting going toe include that n
  • 00:13:30
    get package perfect and if I go back
  • 00:13:33
    into that program CS now I can come in
  • 00:13:36
    and I can say varh equals
  • 00:13:40
    builder. add Rus and then give it a name
  • 00:13:43
    okay so just like that and then I can
  • 00:13:46
    say Okay store let me say with reference
  • 00:13:49
    let me add the cache all right now at
  • 00:13:52
    this point I would need to go Implement
  • 00:13:54
    caching actually in the Blazer project
  • 00:13:56
    now again I would need to go figure out
  • 00:13:58
    the correct get packages and all the
  • 00:14:00
    things that I would need inside this
  • 00:14:01
    project but nice thing about Don Aspire
  • 00:14:03
    is I can add a donet Aspire package now
  • 00:14:06
    in this case this is a component so this
  • 00:14:08
    is a little bit different I could come
  • 00:14:10
    in and I could add here the myet 8
  • 00:14:13
    version of of this package for the
  • 00:14:15
    Aspire stack exchange rdus and this is
  • 00:14:18
    the reddis client that would integrate
  • 00:14:20
    into the Blazer project I could add
  • 00:14:23
    output caching distributed caching
  • 00:14:25
    whichever ones that I need inside this
  • 00:14:27
    project here are all going to be
  • 00:14:28
    available to me and there are tons of
  • 00:14:30
    different components not only
  • 00:14:32
    specifically for here the hosting model
  • 00:14:34
    to add these things there's tons of
  • 00:14:37
    azure SQL we have MySQL we have
  • 00:14:39
    postgress we have all different things
  • 00:14:40
    inside of here which is really nice same
  • 00:14:43
    thing on the um clients as well we have
  • 00:14:47
    all these different ones if I wanted to
  • 00:14:48
    add messaging here with hubs for example
  • 00:14:51
    if I wanted to add aure D data tables or
  • 00:14:53
    Cosmos DB they're all here ready to go
  • 00:14:56
    there's even of course postgress SQL as
  • 00:14:58
    well we take a a look at that in a
  • 00:14:59
    second so we could add those in there
  • 00:15:01
    but let's just see what happens if I add
  • 00:15:02
    it here to the back end this one line of
  • 00:15:04
    code we're adding it with reference and
  • 00:15:06
    all I'm going to do is go ahead and run
  • 00:15:09
    the application again so all I did was
  • 00:15:11
    add a new get package and add this ad
  • 00:15:14
    rdus here so here we go here's our local
  • 00:15:17
    host and we will see that the container
  • 00:15:19
    is now here and it's starting up and
  • 00:15:21
    it's reddis
  • 00:15:22
    724 now it's interesting here that it's
  • 00:15:25
    starting and now running on this TCP you
  • 00:15:27
    might be wondering well where does this
  • 00:15:29
    container where's that running well it's
  • 00:15:30
    cuz I have Docker desktop running here
  • 00:15:33
    in fact I can see that here's my image
  • 00:15:35
    for reddis it's ready to use it was just
  • 00:15:36
    downloaded actually and then the
  • 00:15:38
    container here so here's the container
  • 00:15:40
    it's running and then I would use the
  • 00:15:42
    redis cache container just right there
  • 00:15:44
    and be Off to the Races ready to go
  • 00:15:47
    which is pretty awesome okay what else
  • 00:15:50
    can I do right like let's really stress
  • 00:15:52
    test this thing and some of the
  • 00:15:53
    Simplicity that Aspire adds so I'm going
  • 00:15:56
    to go back into the appost add again I'm
  • 00:15:59
    going to do an Aspire package and let's
  • 00:16:01
    go ahead and add the post grass in here
  • 00:16:05
    so I'm say post and postgress here and
  • 00:16:08
    again I'm going to add 8.0 package
  • 00:16:11
    perfect and then we're just going to
  • 00:16:12
    apply that here
  • 00:16:14
    rad and if you wanted to spin up an
  • 00:16:17
    entire postgress back end right it's
  • 00:16:19
    going to be quite a lot to learn well
  • 00:16:20
    now it's down Aspire here I can go in
  • 00:16:23
    and I'm going to say VAR DB equals
  • 00:16:27
    builder. add postgress yeah you you
  • 00:16:30
    probably guessed it yeah I'm going to
  • 00:16:32
    say DB in here and then I will say now
  • 00:16:34
    with a PG admin let me just add a
  • 00:16:36
    postgress admin inside of here why not
  • 00:16:38
    now in this case the backend would
  • 00:16:40
    probably use this right so I could say
  • 00:16:42
    uh with reference here and then I would
  • 00:16:45
    say DB and then now automatically with
  • 00:16:47
    the service Discovery I could then add
  • 00:16:50
    that client into the the products get
  • 00:16:53
    that reference with the DB and I'd get
  • 00:16:54
    that DB coming back to me so again let's
  • 00:16:56
    go ahead and run this here now I want to
  • 00:16:58
    show you here that we're going to have
  • 00:17:01
    our images that are going to need to be
  • 00:17:03
    downloaded I don't have any other images
  • 00:17:04
    just the reddest one and what we'll see
  • 00:17:07
    here is that we now have the cache
  • 00:17:10
    that's running super fast because it's
  • 00:17:11
    already downloaded the container image
  • 00:17:14
    the database and the PG admin are all
  • 00:17:16
    going to be up here and it's going to
  • 00:17:18
    download hopefully on my relatively fast
  • 00:17:20
    internet and pop up inside of the images
  • 00:17:23
    so once those get downloaded basically
  • 00:17:26
    down and Aspire we'll wait for it so
  • 00:17:28
    there's post scrp it's in use now we can
  • 00:17:30
    actually take a look at the container
  • 00:17:32
    there it is automatically running for me
  • 00:17:34
    if I come back over it next up is going
  • 00:17:37
    to be the uh PG admin there it is PG
  • 00:17:41
    admin 4 let me go and zoom in here we
  • 00:17:43
    can see them there the versions that are
  • 00:17:44
    coming in uh and then we can see the
  • 00:17:48
    container is in use so nothing is
  • 00:17:49
    happening there so that's really cool I
  • 00:17:51
    can go ahead and tap on that PG admin
  • 00:17:53
    URL and it's going to bring me to SL
  • 00:17:55
    browser sometimes on some computers
  • 00:17:57
    takes like 30 seconds or minutes to
  • 00:17:58
    start up based on how fast it is but
  • 00:18:00
    we're now going to see the Aspire
  • 00:18:01
    instance databases we're going to see
  • 00:18:03
    the postest it's going to see all the
  • 00:18:04
    normal PG admin stuff all configured
  • 00:18:07
    automatically for us which is super
  • 00:18:10
    duper rad which is cool so now I also
  • 00:18:13
    love this where we have like all the
  • 00:18:14
    containers running if I just go ahead
  • 00:18:16
    and like shut this down what we're going
  • 00:18:17
    to see is like boom it's going to shut
  • 00:18:18
    down all the containers and everything's
  • 00:18:20
    going to be handled for us automatically
  • 00:18:22
    okay so there's one more thing that I
  • 00:18:23
    want to talk about here too is by
  • 00:18:25
    default here on this reddis we are using
  • 00:18:28
    the default reddis container image so
  • 00:18:30
    724 is what it shows here now one nice
  • 00:18:33
    thing is that it's just sort of like the
  • 00:18:35
    reddest implementation there's other
  • 00:18:36
    sort of implementations that work with
  • 00:18:38
    the API there so for example we could
  • 00:18:40
    use Garnett which is a remote Cache
  • 00:18:42
    Store from the Microsoft research team
  • 00:18:44
    and this is cool because it also works
  • 00:18:45
    with existing rdus clients so let's go
  • 00:18:47
    ahead and like check this out right so
  • 00:18:49
    here I'm going to go into docs I'm going
  • 00:18:51
    to go into the
  • 00:18:53
    releases and if I scroll down I'm just
  • 00:18:55
    going to go ahead and copy the uh
  • 00:18:58
    container Reg
  • 00:18:59
    for Garnett and then what I'm going to
  • 00:19:01
    do here is on this add Rusk I'm going to
  • 00:19:05
    say with over here and there's going to
  • 00:19:08
    be all these different things so with
  • 00:19:09
    redis Commander with TLP export but I
  • 00:19:12
    can actually say with image I'm going to
  • 00:19:15
    say please use this image and then I'm
  • 00:19:18
    going to say with image tag I'm going to
  • 00:19:21
    say latest all right so when I do that
  • 00:19:25
    this is now going to use the Garnett 14
  • 00:19:28
    for us automatically so if I go back
  • 00:19:29
    into my images we're going to see that
  • 00:19:32
    when this spins up the post grass the
  • 00:19:35
    the DB admin those are going to be in
  • 00:19:37
    use but the reddest one won't so you're
  • 00:19:38
    going to notice here that starting it's
  • 00:19:41
    running but oh the source here is the
  • 00:19:43
    Garnett latest tag and that's going to
  • 00:19:45
    go ahead and download that container
  • 00:19:47
    image there it is right there it's
  • 00:19:48
    already in use totally good to go and we
  • 00:19:51
    now have our endpoint I can view my logs
  • 00:19:53
    and sure enough there is Garnett ready
  • 00:19:56
    to go all all set automatically for us
  • 00:20:01
    and that is really from start to finish
  • 00:20:03
    being able to easily configure dad
  • 00:20:07
    Aspire in your application look how
  • 00:20:08
    beautiful this is using a postgress
  • 00:20:10
    database with PG admin with rtis withy
  • 00:20:14
    Garnett using service Discovery all
  • 00:20:16
    configured for us automatically and then
  • 00:20:19
    next up of course is we can easily
  • 00:20:20
    deploy this into cloud backends and
  • 00:20:23
    that's really how easy it is and how
  • 00:20:24
    this amazing orchestrator support in
  • 00:20:26
    Visual Studio 2022 all handed everything
  • 00:20:29
    for
  • 00:20:31
    you all right there you have it from
  • 00:20:34
    start to finish taking the sample adding
  • 00:20:37
    in the back end toet Aspire adding the
  • 00:20:40
    front end to donet Aspire adding post
  • 00:20:43
    grass adding redus using Garnett
  • 00:20:46
    checking out and how it handles
  • 00:20:48
    everything in Docker desktop and
  • 00:20:49
    everything for you automatically now of
  • 00:20:51
    course the next part is actually
  • 00:20:52
    deploying it right so actually deploying
  • 00:20:54
    it using something like Azure container
  • 00:20:56
    apps you can actually right click
  • 00:20:57
    publish directly from Visual Studio
  • 00:20:58
    Studio I'll put a link to all the
  • 00:21:00
    documentation below there's a great
  • 00:21:01
    tutorial walkthr that shows you this in
  • 00:21:03
    detail but I wanted to use this as a
  • 00:21:05
    more of a going a little bit further
  • 00:21:07
    explaining things in more details if
  • 00:21:09
    you're using donet Aspire in your
  • 00:21:10
    applications let me know in the comments
  • 00:21:12
    below if you're brand new and you want
  • 00:21:14
    more of a introductory uh uh video out
  • 00:21:16
    there there's great videos by other
  • 00:21:18
    community members kind of walking
  • 00:21:19
    through file new but I want to kind of
  • 00:21:20
    show how to set this up but I'll put a
  • 00:21:23
    few links as well to um David Fowler and
  • 00:21:26
    Glenn and other folks that are building
  • 00:21:27
    Don fire their sessions from donet comp
  • 00:21:30
    the community standups that they've done
  • 00:21:32
    check out those additional links in the
  • 00:21:33
    show notes below if you have any
  • 00:21:35
    questions at all leave it below of
  • 00:21:36
    course uh and of course thanks for
  • 00:21:38
    watching if you did enjoy this video
  • 00:21:39
    give it a thumbs up it really helps the
  • 00:21:41
    channel and of course jam on that
  • 00:21:42
    subscribe button I'd really appreciate
  • 00:21:44
    it so until next time thanks for
  • 00:21:48
    [Music]
  • 00:21:57
    watching
  • 00:21:58
    [Music]
  • 00:22:00
    oh
标签
  • .NET Aspire
  • cloud-native
  • distributed applications
  • service discovery
  • telemetry
  • Blazor
  • Redis
  • PostgreSQL
  • Docker
  • Azure