In this guide, you'll learn how to architect your ASP. NET Core applications to best take advantage of these capabilities. This guide has been revised to cover. NET 6. That's why the book version has also been updated to version 6. This guide provides end-to-end guidance on building monolithic web applications using ASP. NET Core and Azure. In this context, "monolithic" refers to the fact that these applications are deployed as a single unit, not as a collection of interacting services and applications.
In some contexts, the term monolith may be used as a pejorative, but in the vast majority of situations a single application is much easier to build, deploy, and debug than an app composed of many different services, while still achieving the business requirements. This guide is complementary to ".
NET Microservices. Architecture for Containerized. NET Applications " , which focuses more on Docker, microservices, and deployment of containers to host enterprise applications. The audience for this guide is mainly developers, development leads, and architects who are interested in building modern web applications using Microsoft technologies and services in the cloud.
A secondary audience is technical decision makers who are already familiar ASP. NET Core for new or existing projects. This guide has been condensed into a relatively small document that focuses on building web applications with modern. NET technologies and Azure. As such, it can be read in its entirety to provide a foundation of understanding such applications and their technical considerations. In the editor, you'll see C code that includes text for the "application description" area of the About page.
Change the "application description" message text to read " What's my message? Next, open Visual Studio by using the Run as administrator option from the right-click context menu. Then, run the application again. Congratulations on completing this Quickstart! We hope you learned slightly about C , ASP. In the Solution Explorer , expand the Pages folder, and then choose Index.
This file corresponds to a page that's named Home in the web app, which runs in a web browser. Get started with C and ASP. NET in Visual Studio. Container Tools in Visual Studio. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode.
Is this page helpful? Please rate your experience Yes No. Any additional feedback? Choose your theme optional This quickstart tutorial includes screenshots that use the dark theme.
Open Visual Studio Note If you don't see the. You might have to close Visual Studio before you can continue installing the new workload. Note If you don't see ASP. In the start window, choose Create a new project.
Note If you don't see the ASP. Change the "Welcome" text to read " Hello World! The Docker hosts can be managed with commands like docker run performed manually, or through automation such as Continuous Delivery CD pipelines. There are benefits of using containers to manage monolithic application deployments. Scaling the instances of containers is far faster and easier than deploying additional VMs.
Even when using virtual machine scale sets to scale VMs, they take time to create. When deployed as app instances, the configuration of the app is managed as part of the VM. Deploying updates as Docker images is far faster and network efficient.
Docker Images typically start in seconds, speeding rollouts. Tearing down a Docker instance is as easy as issuing a docker stop command, typically completing in less than a second. As containers are inherently immutable by design, you never need to worry about corrupted VMs, whereas update scripts might forget to account for some specific configuration or file left on the disk. You can use Docker containers for a monolithic deployment of simpler web applications. This approach improves continuous integration and continuous deployment pipelines and helps achieve deployment-to-production success.
A microservices-based architecture has many benefits, but those benefits come at a cost of increased complexity. In some cases, the costs outweigh the benefits, so a monolithic deployment application running in a single container or in just a few containers is a better option.
A monolithic application might not be easily decomposable into well-separated microservices. Microservices should work independently of each other to provide a more resilient application. If you can't deliver independent feature slices of the application, separating it only adds complexity. An application might not yet need to scale features independently.
Many applications, when they need to scale beyond a single instance, can do so through the relatively simple process of cloning that entire instance. The additional work to separate the application into discrete services provides a minimal benefit when scaling full instances of the application is simple and cost-effective. Early in the development of an application, you might not have a clear idea where the natural functional boundaries are.
As you develop a minimum viable product, the natural separation might not yet have emerged. Some of these conditions might be temporary.
You might start by creating a monolithic application, and later separate some features to be developed and deployed as microservices.
Other conditions might be essential to the application's problem space, meaning that the application might never be broken into multiple microservices.
Separating an application into many discrete processes also introduces overhead. There's more complexity in separating features into different processes. The communication protocols become more complex. Instead of method calls, you must use asynchronous communications between services. As you move to a microservices architecture, you need to add many of the building blocks implemented in the microservices version of the eShopOnContainers application: event bus handling, message resiliency and retries, eventual consistency, and more.
The much simpler eShopOnWeb reference application supports single-container monolithic container usage. Optionally, you can run the application's Blazor-based admin component, which requires a separate API project to run as well. The application can be launched from the solution root using the docker-compose build and docker-compose up commands. This command configures a container for the web instance, using the Dockerfile found in the web project's root, and runs the container on a specified port.
You can download the source for this application from GitHub and run it locally. Even this monolithic application benefits from being deployed in a container environment. For one, the containerized deployment means that every instance of the application runs in the same environment.
This approach includes the developer environment where early testing and development take place. The development team can run the application in a containerized environment that matches the production environment. In addition, containerized applications scale out at a lower cost. Using a container environment enables greater resource sharing than traditional VM environments. Finally, containerizing the application forces a separation between the business logic and the storage server. As the application scales out, the multiple containers will all rely on a single physical storage medium.
This storage medium would typically be a high-availability server running a SQL Server database. The eShopOnWeb project runs on. Therefore, it can run in either Linux-based or Windows-based containers. Linux-based containers allow a smaller footprint and are preferred. This step adds the files required and modifies the project to use them. The current eShopOnWeb sample already has these files in place. The solution-level docker-compose. The file allows you to use the docker-compose command to launch multiple applications at the same time.
In this case, it is only launching the Web project. You can also use it to configure dependencies, such as a separate database container. The docker-compose. The Dockerfile is used to specify which base container will be used and how the application will be configured on it.
The Web ' Dockerfile :. Once you run the containerized application, it continues to run until you stop it. You can view which containers are running with the docker ps command. You can stop a running container by using the docker stop command and specifying the container ID. Note that running Docker containers may be bound to ports you might otherwise try to use in your development environment. If you try to run or debug an application using the same port as a running Docker container, you'll get an error stating that the server can't bind to that port.
Once again, stopping the container should resolve the issue. If you want to add Docker support to your application using Visual Studio, make sure Docker Desktop is running when you do so. The wizard won't run correctly if Docker Desktop isn't running when you start the wizard.
In addition, the wizard examines your current container choice to add the correct Docker support. If you want to add, support for Windows Containers, you need to run the wizard while you have Docker Desktop running with Windows Containers configured.
If you want to add, support for Linux containers, run the wizard while you have Docker running with Linux containers configured. Previous Next. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info.
Contents Exit focus mode. Is this page helpful? Please rate your experience Yes No.
0コメント