使用 ASP.NET Core 和 Azure 构建新式 Web 应用程序Architect Modern Web Applications with ASP.NET Core and Azure

“架构新式 Web 应用程序”指南的封面图像。

发布者PUBLISHED BY

Microsoft 开发人员部门、.NET 和 Visual Studio 产品团队Microsoft Developer Division, .NET, and Visual Studio product teams

Microsoft Corporation 的一个部门A division of Microsoft Corporation

One Microsoft WayOne Microsoft Way

Redmond, Washington 98052-6399Redmond, Washington 98052-6399

版权所有 © 2019 Microsoft CorporationCopyright © 2019 by Microsoft Corporation

保留所有权利。All rights reserved. 未经发布者书面许可,不得以任何形式或任何方式复制或传播本书中的任何内容。No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher.

本书“按原样”提供,表达作者的观点和看法。This book is provided “as-is” and expresses the author’s views and opinions. 本书中表达的观点、看法和信息(包括 URL 和其他 Internet 网站引用)如有更改,恕不另行通知。The views, opinions and information expressed in this book, including URL and other Internet website references, may change without notice.

本书中提及的一些示例仅用于说明,纯属虚构。Some examples depicted herein are provided for illustration only and are fictitious. 不存在任何实际关联或联系,请勿妄加推断。No real association or connection is intended or should be inferred.

Microsoft 和 https://www.microsoft.com 上“商标”网页列出的商标是 Microsoft 集团公司的商标。Microsoft and the trademarks listed at https://www.microsoft.com on the “Trademarks” webpage are trademarks of the Microsoft group of companies.

Mac 和 macOS 是 Apple Inc. 的商标Mac and macOS are trademarks of Apple Inc.

Docker 的鲸鱼徽标是 Docker Inc. 的注册商标经许可方可使用。The Docker whale logo is a registered trademark of Docker, Inc. Used by permission.

所有其他标记和徽标均为其各自所有者的财产。All other marks and logos are property of their respective owners.

作者:Author:

Steve "ardalis" Smith - 软件设计师及培训师 - Ardalis.comSteve "ardalis" Smith - Software Architect and Trainer - Ardalis.com

编辑:Editors:

Maira Wenzel Maira Wenzel

介绍Introduction

相比传统 .NET 开发,.NET Core 和 ASP.NET Core 具有一系列优势。.NET Core and ASP.NET Core offer several advantages over traditional .NET development. 如果以下所有方面或一些方面对于你的应用程序成功至关重要,应将 .NET Core 用于服务器应用程序:You should use .NET Core for your server applications if some or all of the following are important to your application's success:

  • 跨平台支持。Cross-platform support.

  • 微服务的使用。Use of microservices.

  • Docker 容器的使用。Use of Docker containers.

  • 高性能和可伸缩性需求。High performance and scalability requirements.

  • 在同一服务器上通过应用程序对 .NET 版本进行并行版本控制。Side-by-side versioning of .NET versions by application on the same server.

传统 .NET 应用程序虽然支持许多以上要求,但是 ASP.NET Core 和 .NET Core 已经过优化,可为以上方案提供完善的支持。Traditional .NET applications can and do support many of these requirements, but ASP.NET Core and .NET Core have been optimized to offer improved support for the above scenarios.

越来越多的组织选择使用 Microsoft Azure 等服务,在云中托管 web 应用程序。More and more organizations are choosing to host their web applications in the cloud using services like Microsoft Azure. 如果以下方面对你的应用程序或组织至关重要,应该考虑在云中托管应用程序:You should consider hosting your application in the cloud if the following are important to your application or organization:

  • 减少对数据中心的成本投入(硬件、软件、空间、实用工具、服务器管理等)Reduced investment in data center costs (hardware, software, space, utilities, server management, etc.)

  • 灵活的定价(基于使用情况付费,无需为空闲容量付费)。Flexible pricing (pay based on usage, not for idle capacity).

  • 高可靠性。Extreme reliability.

  • 改善应用移动性;可轻松更改部署应用的位置和方式。Improved app mobility; easily change where and how your app is deployed.

  • 灵活的容量;基于实际需要增加或减少。Flexible capacity; scale up or down based on actual needs.

使用 Azure 中托管的 ASP.NET Core 生成 Web 应用,与传统替代方法相比,这能提供许多竞争优势。Building web applications with ASP.NET Core, hosted in Azure, offers many competitive advantages over traditional alternatives. ASP.NET Core 针对新式 web 应用程序开发做法和云托管方案进行了优化。ASP.NET Core is optimized for modern web application development practices and cloud hosting scenarios. 本指南介绍如何构建 ASP.NET Core 应用程序以充分利用这些功能。In this guide, you'll learn how to architect your ASP.NET Core applications to best take advantage of these capabilities.

目标Purpose

本指南提供了使用 ASP.NET Core 和 Azure 构建单片 Web 应用程序的端到端指导 。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.

本指南是.NET 微服务 - 容器化 .NET 应用程序体系结构的补充,该文章更侧重于介绍 Docker、微服务和部署容器以托管企业应用程序。This guide is complementary to the ".NET Microservices. Architecture for Containerized .NET Applications" which focuses more on Docker, Microservices, and Deployment of Containers to host enterprise applications.

.NET 微服务。.NET Microservices. 适用于容器化 .NET 应用程序的体系结构Architecture for Containerized .NET Applications

本指南的目标读者Who should use this guide

本指南的受众主要是对使用云中的 Microsoft 技术和服务生成新式 web 应用程序感兴趣的开发者、开发潜在顾客和架构师。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.

次要受众是技术决策者,他们已经熟悉 ASP.NET 或 Azure,并想要了解是否需要为新项目或现有项目升级到 ASP.NET Core。A secondary audience is technical decision makers who are already familiar ASP.NET or Azure and are looking for information on whether it makes sense to upgrade to ASP.NET Core for new or existing projects.

如何使用本指南How you can use this guide

本指南已精简为较小的文档,侧重介绍如何使用新式 .NET 技术和 Windows Azure 生成 web 应用程序。This guide has been condensed into a relatively small document that focuses on building web applications with modern .NET technologies and Windows Azure. 可通读本指南,了解有关此类应用程序及其技术注意事项的基本信息。As such, it can be read in its entirety to provide a foundation of understanding such applications and their technical considerations. 本指南及其示例应用程序还可作为操作起点或参考。The guide, along with its sample application, can also serve as a starting point or reference. 可将相关示例应用程序作为你自己的应用程序的模板,或者了解如何组织应用程序的组件部件。Use the associated sample application as a template for your own applications, or to see how you might organize your application's component parts. 在对自己的应用程序进行选择权衡时,请参考指南的原则、体系结构的范围以及技术选项和决策注意事项。Refer back to the guide's principles and coverage of architecture and technology options and decision considerations when you're weighing these choices for your own application.

请将本指南转发到团队中,这有助于确保对这些注意事项和机会的共同理解。Feel free to forward this guide to your team to help ensure a common understanding of these considerations and opportunities. 确保每个人使用共同的术语和基础原则工作,这有助于构建模式和做法的一致应用。Having everybody working from a common set of terminology and underlying principles helps ensure consistent application of architectural patterns and practices.

参考资料References