利用 Azure 雲端服務及 Windows 容器將現有的 .NET 應用程式現代化 (第 2 版)Modernize existing .NET applications with Azure cloud and Windows Containers (2nd edition)

將 .NET 應用程式現代化指南的封面影像。

Microsoft CorporationMicrosoft Press and Microsoft DevDiv
Microsoft Press 及 Microsoft DevDiv 部門Divisions of Microsoft Corporation
One Microsoft WayOne Microsoft Way
Redmond, Washington 98052-6399Redmond, Washington 98052-6399

版權© 2020 年由微軟公司Copyright © 2020 by Microsoft Corporation

著作權所有,並保留一切權利。All rights reserved. 本書內容的任何部分在未經過發行者書面許可下,不得以任何形式或透過任何方式進行重製。No part of the contents of this book may be reproduced in any form or by any means without the written permission of the publisher.

本書免費提供,為電子書的格式,可以從 Microsoft 的多種不同管道取得,例如 https://dot.net/architectureThis book is available for free in the form of an electronic book (e-book) available through multiple channels at Microsoft such as https://dot.net/architecture.

如果您有與本書相關的問題,請發送電子郵件至dotnet-architecture-ebooks-feedback@service.microsoft.comIf you have questions related to this book, email at dotnet-architecture-ebooks-feedback@service.microsoft.com.

本書依照「現況」提供,代表作者的觀點和意見。This book is provided "as-is" and expresses the author's views and opinions. 本書中所述之觀點、意見與資訊 (包括 URL 及其他網際網路的網站參考) 如有變更,恕不另行通知。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. 所有其他商標皆屬於其各自擁有者的財產。All other marks are property of their respective owners.


塞薩爾德拉托雷, Sr. PM, .NET 產品團隊, 微軟公司.Cesar de la Torre, Sr. PM, .NET Product Team, Microsoft Corp.

參與者和檢閱者:Participants and reviewers:

Scott Hunter,Microsoft .NET 小組合夥人暨 PM 主管Scott Hunter, Partner Director PM, .NET team, Microsoft
Paul Yuknewicz,Microsoft Visual Studio Tools 小組首席 PM 經理Paul Yuknewicz, Principal PM Manager, Visual Studio Tools team, Microsoft
Lisa Guthrie,Microsoft Visual Studio Tools 小組資深專案經理Lisa Guthrie, Sr. PM, Visual Studio Tools team, Microsoft
Ankit Asthana,Microsoft .NET 小組 PM 總經理Ankit Asthana, Principal PM Manager, .NET team, Microsoft
Unai Zorrilla,Plain Concepts 開發人員主管Unai Zorrilla, Developer Lead, Plain Concepts
Javier Valero,Grupo Solutio 營運長Javier Valero, Chief Operating Officer at Grupo Solutio


當您決定要將 Web 應用程式或服務現代化,並將其移至雲端時,您未必需要全面重新建構您的應用程式。When you decide to modernize your web applications or services and move them to the cloud, you don't necessarily have to fully rearchitect your apps. 基於成本和時間的限制,使用微服務這類先進方法來重新建構應用程式,不一定每次都適合。Rearchitecting an application by using an advanced approach like microservices isn't always an option because of cost and time restraints. 重新建構應用程式也不是必然,必須取決於應用程式的類型。Depending on the type of application, rearchitecting an app also might not be necessary. 為了讓組織的雲端移轉策略發揮最高成本效益,考量您的業務需求與應用程式需求便成了重要的一環。To optimize the cost-effectiveness of your organization's cloud migration strategy, it's important to consider the needs of your business and requirements of your apps. 您必須判斷:You'll need to determine:

  • 哪些應用程式需要轉換或重新建構。Which apps require a transformation or rearchitecting.

  • 哪些應用程式只需要進行部分修改。Which apps need to be only partially modernized.

  • 哪些應用程式沒辦法直接「隨即轉移」到雲端。Which apps you can "lift and shift" directly to the cloud.

關於本指南About this guide

本指南主要著重於現有 Microsoft .NET Framework Web 應用程式或服務導向應用程式的第一次現代化,意即將工作負載移至較新或更現代化環境的動作,所以不會大幅改變應用程式的程式碼與基本架構。This guide focuses primarily on initial modernization of existing Microsoft .NET Framework web or service-oriented applications, meaning the action of moving a workload to a newer or more modern environment without significantly altering the application's code and basic architecture.

本指南也摘要列出將應用程式移至雲端,以及使用特定一組新技術及方法 (例如 Windows 容器及 Azure 支援之 Windows 容器中的相關計算平台),將應用程式局部現代化的好處。This guide also highlights the benefits of moving your apps to the cloud and partially modernizing apps by using a specific set of new technologies and approaches, like Windows Containers and related compute-platforms in Azure supporting Windows Containers.

現有 .NET 應用程式前往雲端的路徑Path to the cloud for existing .NET applications

組織通常會選擇移至雲端以提升其應用程式的靈活度與速度。Organizations typically choose to move to the cloud for the agility and speed they can get for their applications. 您可以在數分內於雲端設置上千個伺服器 (VM),相較之下,設置內部部署伺服器通常需要幾個禮拜的時間。You can set up thousands of servers (VMs) in the cloud in minutes, compared to the weeks it typically takes to set up on-premises servers.

將應用程式移轉到雲端並沒有一體適用的策略。There isn't a single, one-size-fits-all strategy for migrating applications to the cloud. 適合您的移轉策略取決於組織的需求與優先順序,以及所要移轉的應用程式種類。The right migration strategy for you will depend on your organization's needs and priorities, and the kind of applications you are migrating. 並非所有應用程式都適合移至平台即服務 (PaaS) 模型,或是開發雲端原生應用程式模型。Not all applications warrant the investment of moving to a platform as a service (PaaS) model or developing a cloud-native application model. 在許多情況下,您可以根據業務需求,使用分階或累進式方法將資產移至雲端。In many cases, you can take a phased or incremental approach to invest in moving your assets to the cloud, based on your business needs.

對於組織中,可以長期保持敏捷度與價值的現代應用程式,投資雲端原生應用程式架構可能會對您有所助益;For modern applications with the best long-term agility and value for the organization, you might benefit from investing in cloud-native application architectures. 但對於現有或舊版資產的應用程式,其關鍵在於如何花最少的時間與金錢,將這些應用程式移至雲端 (不重新建構或變更程式碼),以從中獲取最大的利益。However, for applications that are existing or legacy assets, the key is to spend minimal time and money (no rearchitecting or code changes) while moving them to the cloud, to realize significant benefits.

圖 1-1 呈現了您採取累進方式將現有的 .NET 應用程式移至雲端時,可以採用的路徑。Figure 1-1 shows the possible paths you can take when you move existing .NET applications to the cloud in incremental phases.

 現有 .NET 應用程式及服務的現代化路徑

圖 1-1.Figure 1-1. 現有 .NET 應用程式及服務的現代化路徑Modernization paths for existing .NET applications and services

每個移轉方法都有其優點及使用理由。Each migration approach has different benefits and reasons for using it. 在將應用程式移至雲端時,您可以選擇單一方法,也可以從多種方法中擷取某些元件。You can choose a single approach when you migrate apps to the cloud, or choose certain components from multiple approaches. 個別應用程式並不侷限於單一方法或成熟度。Individual applications aren't limited to a single approach or maturity state. 比方說,一般混合方法會有某些內部部署元件,再加上雲端中的其他元件。For instance, a common hybrid approach would have certain on-premises components plus other components in the cloud.

以下是每個應用程式成熟度等級的定義及簡短說明:The definition and short explanation for each application maturity level are the following:

級別 1:雲基礎架構就緒應用程式:在此遷移方法中,只需將當前本地應用程式作為服務(IaaS)平臺遷移或重新託管到基礎結構。Level 1: Cloud Infrastructure-Ready applications: In this migration approach, you simply migrate or rehost your current on-premises applications to an infrastructure as a service (IaaS) platform. 您的應用程式結構和以前幾乎相同,但您現已將其部署到雲端中的 VM。Your apps have almost the same composition as before, but now you deploy them to VMs in the cloud. 這種簡單的移轉類型在業界我們稱為「原形移轉」。This simple type of migration is typically known in the industry as "Lift & Shift."

級別 2:雲優化應用程式:在此級別,並且仍然無需重新構建或更改重要代碼,您可以通過容器和其他雲託管服務等現代技術在雲中運行應用,從而獲得其他好處。Level 2: Cloud Optimized applications: At this level and still without rearchitecting or altering significant code, you can gain additional benefits from running your app in the cloud with modern technologies like containers and additional cloud-managed services. 您可藉由精簡企業開發營運 (DevOps) 程序來增加應用程式的靈活度,加快出貨速度。You improve the agility of your applications to ship faster by refining your enterprise development operations (DevOps) processes. 您可以使用採用 Docker 引擎的 Windows 容器等技術來達到此目的。You achieve this by using technologies like Windows Containers, which is based on Docker Engine. 容器免除了在多個階段部署時,因應用程式相依性而引起的衝突。Containers remove the friction that’s caused by application dependencies when you deploy in multiple stages. 在此成熟度模型中,您一方面可以在 IaaS 或 PaaS 上部署容器,一方面可以利用更多雲端管的資料庫服務、快取即服務、監視及持續整合/持續部署 (CI/CD) 管線服務等等。In this maturity model, you can deploy containers on IaaS or PaaS while using additional cloud-managed services related to databases, cache as a service, monitoring, and continuous integration/continuous deployment (CI/CD) pipelines.

第三等級的成熟度是雲端的終極目標,但對大多數應用程式而言並非必要,且非本指南的主要重點:The third level of maturity is the ultimate goal in the cloud, but it's optional for many apps and not the main focus of this guide:

級別 3:雲原生應用程式:此遷移方法通常由業務需求驅動,並針對任務關鍵型應用程式的現代化目標。Level 3: Cloud-Native applications: This migration approach typically is driven by business need and targets modernizing your mission-critical applications. 在此等級中,您可使用 PaaS 服務將您的應用程式移至 PaaS 運算平台上。At this level, you use PaaS services to move your apps to PaaS computing platforms. 您可以實作雲端原生應用程式及微服務架構,來發展具長期靈活度的應用程式,以及擴展新界限。You implement cloud-native applications and microservices architecture to evolve applications with long-term agility, and to scale to new limits. 這種類型的現代化通常需要專為雲端設計的架構。This type of modernization usually requires architecting specifically for the cloud. 尤其在移至雲端原生應用程式及微服務式模型的時候,通常會需要撰寫新的程式碼。New code often must be written, especially when you move to cloud-native application and microservice-based models. 這項方法可協助您取得在整合型及內部部署應用程式環境中難以達到的優點。This approach can help you gain benefits that are difficult to achieve in your monolithic and on-premises application environment.

表 1-1 描述了選擇各項移轉或現代化方法的主要優點及理由。Table 1-1 describes the main benefits of and reasons for choosing each migration or modernization approach.

雲端基礎結構就緒Cloud Infrastructure-Ready
提升和換檔Lift and shift
現代化、重新架構及重新編寫Modernize, rearchitect and rewrite
應用程式的計算目標Application's compute target
在 Azure 中部署到 VM 的應用程式Applications deployed to VMs in Azure 部署到 Azure App Service、Azure 容器執行個體 (ACI)、搭載容器的 VM 或 AKS (Azure Kubernetes Service) 的整合型或多層式架構 (N-Tier) 應用程式Monolithic or N-Tier apps deployed to Azure App Service, Azure Container Instance (ACI), VMs with containers, or AKS (Azure Kubernetes Service) 容器化 Azure Kubernetes Service (AKS) 上的微服務及 (或) Azure Functions 上的無伺服器微服務。Containerized microservices on Azure Kubernetes Service (AKS) and/or serverless microservices based on Azure Functions.
資料目標Data target
SQL 或 VM 上的任何關聯式資料庫SQL or any relational database on a VM Azure SQL Database 受控執行個體或雲端中其他的受控資料庫。Azure SQL Database Managed Instance or another managed database in the cloud. 依據 Azure SQL Database、Azure Cosmos DB 或雲端中其他受控資料庫上的微服務微調資料庫Fined-grain databases per microservice, based on Azure SQL Database, Azure Cosmos DB, or another managed database in the cloud
  • 無須重新架構,也無須增加新的程式碼No rearchitecting, no new code
  • 以最少心力快速移轉Least effort for quick migration
  • Azure 中支援的最普及選項Least-common denominator supported in Azure
  • 保證基本可用性Basic availability guarantees
  • 移至雲端後更容易現代化After moving to the cloud, it's easier to modernize even more
  • 無須重新架構No rearchitecting
  • 最少的程式碼/設定變更Minimal code/config changes
  • 因容器而獲得改善的部署及 DevOps 發行靈活度Improved deployment and DevOps agility to release because of containers
  • 增加密度並降低部署成本Increased density and lower deployment costs
  • 應用程式及相依性的可攜性Portability of apps and dependencies
  • 主機目標的靈活性:PaaS 方法或 IaaSFlexibility of host targets: PaaS approaches or IaaS
  • 雲端架構,可以發揮雲端最大效益,但需要編寫新的程式碼Architect for the cloud, you get the best benefits from the cloud but new code is needed
  • 微服務雲端原生方法Microservices cloud-native approaches
  • 現代化的任務關鍵性應用程式,具備可高度靈活調整的雲端復原能力Modern mission-critical applications, cloud-resilient hyper-scalable
  • 完整受控的服務Fully managed services
  • 經最佳化以調整規模Optimized for scale
  • 為子系統的自主靈活度最佳化Optimized for autonomous agility by subsystem
  • 建基於部署及 DevOpsBuilt on deployment and DevOps
  • 挑戰Challenges
  • 除了轉入營業費用或關閉資料中心之外,雲端價值較低Smaller cloud value, other than shift in operating expense or closing datacenters
  • 管理很少:沒有作業系統或中介軟體修補;可能使用基礎結構解決方案,如 Terraform、Spinnaker 或人偶Little is managed: No OS or middleware patching; might use infrastructure solutions, like Terraform, Spinnaker, or Puppet
  • 對於開發人員與 IT 營運來說,容器化是學習曲線之外的另一個步驟Containerizing is an additional step in the learning curve for developers and IT Operations
  • DevOps 與 CI/CD 管線通常是此方式的必備條件。DevOps and CI/CD pipelines are usually ‘a must’ for this approach. 若目前的組織文化中沒有這兩項,就可能形成另一項挑戰If not currently present in the culture of the organization, it might be an additional challenge
  • 需要重新架構雲端原生應用程式及微服務架構,而且在現代化時,通常需要重新分解或重新編寫重要的程式碼 (增加時間及預算)Requires rearchitecture for cloud native apps and microservice architectures and usually requires significant code refactoring or rewriting when modernizing (increased time and budget)
  • 表 1-1。Table 1-1. 現有 .NET 應用程式及服務現代化路徑的優點與挑戰Benefits and challenges of modernization paths for existing .NET applications and services

    依成熟度等級分階的主要技術及架構Key technologies and architectures by maturity level

    .NET Framework 應用程式最初從 2001 年年底推出的 .NET Framework 1.0 版開始。.NET Framework applications initially started with the .NET Framework version 1.0, which was released in late 2001. 之後,公司移往了更新的版本 (例如 2.0、3.5 及 .NET 4.x)。Then, companies moved towards newer versions (such as 2.0, 3.5 and .NET 4.x). 這些應用程式大多在 Windows Server 及 Internet Information Server (IIS) 上執行,而且使用像是 SQL Server、Oracle、MySQL 或任何其他 RDBMS 一類的關聯式資料庫。Most of those applications ran on Windows Server and Internet Information Server (IIS), and used a relational database, like SQL Server, Oracle, MySQL, or any other RDBMS.

    如今,大多數現有的 .NET 應用程式可能以 .NET Framework 4.x 甚至是 .NET Framework 3.5 為基礎,且使用 ASP.NET MVC、ASP.NET Web Forms、ASP.NET Web API、Windows Communication Foundation (WCF)、ASP.NET SignalR 及 ASP.NET Web Pages 等 Web 架構。Most existing .NET applications might nowadays be based on .NET Framework 4.x, or even on .NET Framework 3.5, and use web frameworks like ASP.NET MVC, ASP.NET Web Forms, ASP.NET Web API, Windows Communication Foundation (WCF), ASP.NET SignalR, and ASP.NET Web Pages. 這些已建立的 .NET Framework 技術相依於 Windows。These established .NET Framework technologies depend on Windows. 若您只是想移轉舊版應用程式,而且希望將對應用程式基礎結構產生的變更降至最低,該相依性是重要的考慮因素。That dependency is important to consider if you are simply migrating legacy apps and you want to make minimal changes to your application infrastructure.

    圖 1-2 顯示了在三個雲端成熟度等級中,各自使用的主要技術及架構樣式:Figure 1-2 shows the primary technologies and architecture styles used at each of the three cloud maturity levels:

    各個成熟度等級將現有 .NET Web 應用程式現代化時使用的主要技術

    圖 1-2。Figure 1-2. 各個成熟度等級將現有 .NET Web 應用程式現代化時使用的主要技術Primary technologies for each maturity level for modernizing existing .NET web applications

    圖 1-2 強調了大多數常見案例,然而在架構方面有可能會出現許多混合變化。Figure 1-2 highlights the most common scenarios, but many hybrid and mixed variations are possible when it comes to architecture. 比方說,成熟度模型不僅適用現有 Web 應用程式中的整合型架構,也適用於服務導向、多層式架構 (N-Tier) 及其他架構樣式變化。For example, the maturity models apply not only to monolithic architectures in existing web apps, but also to service orientation, N-Tier, and other architecture style variations. 依賴其中任何一種架構類型及相關技術的程度高低,決定應用程式的整體成熟度等級。The higher focus or percentage on one or another architecture type and related technologies determines the overall maturity level of your applications.

    現代化程序中的每個成熟度等級都與下列主要技術和方法相關:Each maturity level in the modernization process is associated with the following key technologies and approaches:

    • 雲基礎架構就緒(重新託管或基本提升&轉變):作為第一步,許多組織只想快速執行雲遷移策略。Cloud Infrastructure-Ready (rehost or basic lift & shift): As a first step, many organizations want only to quickly execute a cloud-migration strategy. 因此會選擇重新裝載應用程式。In this case, applications are rehosted. 大多數重新裝載作業都能透過使用 Azure Migrate 自動執行,此服務會提供必要的指導、深入解析及機制,協助您透過 Azure Site RecoveryAzure 資料庫移轉服務等雲端工具移轉到雲端。Most rehosting can be automated by using Azure Migrate, a service that provides the guidance, insights, and mechanisms needed to assist you in migrating to Azure based on cloud tools like Azure Site Recovery and Azure Database Migration Service. 您也可以手動設定重新裝載,使您能在將舊版應用程式移至雲端時,了解有關您資產的基礎結構詳細資料。You can also set up rehosting manually, so that you can learn infrastructure details about your assets when you move legacy apps to the cloud. 比方說將應用程式移至 Azure 上的 VM,您可能幾乎完全不需要修改,或可能只需小幅度變更設定即可。For example, you can move your applications to VMs in Azure with little modification-probably with only minor configuration changes. 在此情況中的網路功能與內部部署環境相似,特別是當您在 Azure 中建立虛擬網路的時候。The networking in this case is similar to an on-premises environment, especially if you create virtual networks in Azure.

    • 雲優化(託管服務和 Windows 容器):此模型旨在進行一些重要的部署優化,以便從雲中獲得一些顯著優勢,而無需更改應用程式的核心體系結構。Cloud-Optimized (Managed Services and Windows Containers): This model is about making a few important deployment optimizations to gain some significant benefits from the cloud, without changing the core architecture of the application. 基本步驟是將 Windows 容器支援新增至您現有的 .NET Framework 應用程式。The fundamental step here is to add Windows Containers support to your existing .NET Framework applications. 這項重要的步驟 (容器化) 不會影響程式碼,因此投入原形移轉的整體資源不大。This important step (containerization) doesn't require touching the code, so the overall lift and shift effort is light. 您可以使用 Image2Docker、Visual Studio 以及 Visual Studio Tools for DockerYou can use tools like Image2Docker or Visual Studio, with its tools for Docker. Visual Studio 會自動選擇 ASP.NET 應用程式及 Windows 容器映像的智慧型預設。Visual Studio automatically chooses smart defaults for ASP.NET applications and Windows Containers images. 這些工具提供了迅速的內部迴圈,以及容器到 Azure 的快速路徑,These tools offer both a rapid inner loop, and a fast path to get the containers to Azure. 並改善您部署到多個環境時的靈活度。Your agility is improved when you deploy to multiple environments. 接著進入生產環境,若您偏好 IaaS 方式,您可以將 Windows 容器部署到 Azure Web App for ContainersAzure 容器執行個體 (ACI),以及搭載 Windows Server 2016 與容器的 Azure VM。Then, moving to production, you can deploy your Windows Containers to Azure Web App for Containers, Azure Container Instances (ACI), and Azure VMs with Windows Server 2016 and containers if you prefer an IaaS approach. 對於更複雜的多容器應用程式,請考慮使用 Azure Kubernetes Service (AKS/ACS) 這類的協調器。For more complex multi-container applications, consider using orchestrators like Azure Kubernetes Service (AKS/ACS).

    在第一次現代化期間,您也可以從雲端新增資產,像是使用 Azure Application Insights 之類的工具執行監視;CI/CD 管線應用在 Azure DevOps Services 的應用程式生命週期;以及 Azure 所提供其他更多的資料資源服務。During this initial modernization, you can also add assets from the cloud, such as monitoring with tools like Azure Application Insights; CI/CD pipelines for your app lifecycles with Azure DevOps Services; and many more data resource services that are available in Azure. 比方說,您可以修改原先使用傳統 ASP.NET Web FormsASP.NET MVC 開發的整合型 Web 應用程式,而您現在可以使用 Windows 容器進行部署。For instance, you can modify a monolithic web app that was originally developed by using traditional ASP.NET Web Forms or ASP.NET MVC, but now you deploy it by using Windows Containers. 當您使用 Windows 容器時,也應該將資料移轉到 Azure SQL Database 受控執行個體中的資料庫,這完全不需要變更您應用程式的核心架構。When you use Windows Containers, you should also migrate your data to a database in Azure SQL Database Managed Instance, all without changing the core architecture of your application.

    • 雲原生:如介紹,當您針對大型複雜應用程式時,應考慮構建雲原生應用程式,這些應用程式具有多個獨立開發團隊,這些開發團隊可以自主開發和部署不同的微服務。Cloud-Native: As introduced, you should think about architecting cloud-native applications when you are targeting large and complex applications with multiple independent development teams working on different microservices that can be developed and deployed autonomously. 此外還有每項微服務的微調與獨立調整能力。Also, due to granularized and independent scalability per microservice. 這些架構方式雖然面臨十分重大的挑戰和複雜度,但可以藉由使用雲端 PaaS 和協調器 (像是 Azure Kubernetes Service (AKS/ACS) (受控 Kubernetes)) 大幅簡化,以及在無伺服器方法中使用 Azure FunctionsThese architectural approaches face very important challenges and complexities but can be greatly simplified by using cloud PaaS and orchestrators like Azure Kubernetes Service (AKS/ACS) (managed Kubernetes), and Azure Functions for a serverless approach. 這所有的方法 (例如微服務及無伺服器) 通常會需要雲端架構及編寫適用於特定 PaaS 平台的程式碼,或是編寫符合特定架構 (例如微服務) 的程式碼。All these approaches (like microservices and Serverless) typically require you to architect for the cloud and write new code—code that is adapted to specific PaaS platforms, or code that aligns with specific architectures, like microservices.

    圖 1-3 顯示了您可在每個成熟度等級使用的內部技術:Figure 1-3 shows the internal technologies that you can use for each maturity level:


    圖 1-3。Figure 1-3. 每個現代化成熟度等級的內部技術Internal technologies for each modernization maturity level

    原形移轉案例Lift and shift scenario

    對於隨即轉移,請記得您可以在應用程式案例中使用多種不同的隨即轉移變化。For lift and shift migrations, keep in mind that you can use many different variations of lift and shift in your application scenarios. 如果您只重新裝載應用程式,可能會產生圖 1-4 中的情形,也就是您只在應用程式及資料庫伺服器使用雲端中的 VM。If you only rehost your application, you might have a scenario like the one shown in Figure 1-4, where you use VMs in the cloud only for your application and for your database server.

    雲端中的單純 IaaS 案例範例

    圖 1-4.Figure 1-4. 雲端中的單純 IaaS 案例範例Example of a pure IaaS scenario in the cloud

    現代化案例Modernization scenarios

    在現代化案例中,您可能只會有一個會有一個單純的雲端最佳化應用程式,只使用該成熟度等級的元素。For modernization scenarios, you might have a pure Cloud-Optimized application that uses elements only from that maturity level. 或者,您可能會一個處於中間狀態的應用程式,其中一部分元素來自原有的雲端基礎結構,另一部分元素來自雲端最佳化 (亦即「挑選」或混合式模型),如圖 1-5 所示。Or, you might have an intermediate-state application with some elements from Cloud Infrastructure-Ready and other elements from Cloud-Optimized (a "pick and choose" or mixed model), like in Figure 1-5.

    有 IaaS 上的資料庫、DevOps 及容器化資產的範例「挑選」案例

    圖 1-5。Figure 1-5. 有 IaaS 上的資料庫、DevOps 及容器化資產的範例「挑選」案例Example "pick and choose" scenario, with database on IaaS, DevOps, and containerization assets

    接下來,對於要移轉的許多現有 .NET Framework 應用程式而言,最理想的狀況就是移轉成雲端最佳化應用程式;您只需要花一點工夫,就能換取莫大的好處。Next, as the ideal scenario for many existing .NET Framework applications to migrate, you could migrate to a Cloud-Optimized application, to get significant benefits from little work. 此方法也能讓您準備好隨著未來的演變,融入雲端原生。This approach also sets you up for Cloud-Native as a possible future evolution. 範例請見圖 1-6。Figure 1-6 shows an example.

    雲端最佳化應用程式案例範例,搭載 Windows 容器與受控服務

    圖 1-6。Figure 1-6. 雲端最佳化應用程式案例範例,搭載 Windows 容器與受控服務Example Cloud-Optimized apps scenario, with Windows Containers and managed services

    更進一步來說,您可以針對特定案例新增一些微服務來延伸現有的雲端最佳化應用程式。Going even further, you could extend your existing Cloud-Optimized application by adding a few microservices for specific scenarios. 這會讓您有部分前進到雲端原生模型,但這不是本指導的重點。This would move you partially to the level of Cloud-Native model, which is not the main focus of the present guidance.

    本指南未涵蓋的內容What this guide does not cover

    本指南涵蓋一部份的特定範例案例,如圖 1-7 所示。This guide covers a specific subset of the example scenarios, as shown in Figure 1-7. 本指南僅著重在原形移轉案例,乃至於雲端最佳化模型。This guide focuses only on lift and shift scenarios, and ultimately, on the Cloud-Optimized model. 雲端最佳化模型會使用 Windows 容器加上像是監視和 CI/CD 管線等元件,將 .NET Framework 應用程式現代化。In the Cloud-Optimized model, a .NET Framework application is modernized by using Windows Containers, plus additional components like monitoring and CI/CD pipelines. 若要以快速且具彈性的方式將應用程式部署到雲端,每項元件都是不可或缺的要素。Each component is fundamental to deploying applications to the cloud, faster, and with agility.


    圖 1-7。Figure 1-7. 本指南不包括雲端原生Cloud-Native is not covered in this guide

    本指南的重點很明確。The focus of this guide is specific. 主要在說明如何不重新架構及變更程式碼,就能原形移轉您現有 .NET 應用程式。It shows you the path you can take to achieve a lift and shift of your existing .NET applications, without rearchitecting, and with no code changes. 最後還說明了如何將您的應用程式移轉成雲端最佳化。Ultimately, it shows you how to make your application Cloud-Optimized.

    本指南並未說明如何建立雲端原生應用程式,例如如何演變成微服務架構。This guide doesn't show you how to create Cloud-Native applications, such as how to evolve to a microservices architecture. 要重新構建應用程式或創建基於微服務的全新應用程式,請參閱電子書.NET 微服務:容器化 .NET 應用程式的體系結構To rearchitect your applications or to create brand-new applications that are based on microservices, see the e-book .NET Microservices: Architecture for containerized .NET applications.

    其他資源Additional resources

    • 使用 Microsoft 平臺和工具(可下載電子書)實現容器化 Docker 應用程式生命週期|Containerized Docker application lifecycle with Microsoft platform and tools (downloadable e-book) </span> https://aka.ms/dockerlifecycleebook

    • .NET 微服務:容器化 .NET 應用程式的體系結構(可下載電子書) |.NET Microservices: Architecture for containerized .NET applications (downloadable e-book) </span> https://aka.ms/microservicesebook

    • Architecting modern web applications with ASP.NET Core and Azure (使用 ASP.NET Core 與 Azure 架構現代化 Web 應用程式) (可供下載的電子書) Architecting modern web applications with ASP.NET Core and Azure (downloadable e-book)

    誰應該使用本指南Who should use this guide

    本指南的對象為想要將採用 .NET Framework 之現有 ASP.NET 應用程式或 WCF 服務現代化,以提升交貨及行應用程式之敏捷度的開發人員及解決方案架構設計師。This guide was written for developers and solution architects who want to modernize existing ASP.NET web applications or WCF services that are based on the .NET Framework, for improved agility in shipping and releasing applications.

    如果您是技術決策者,例如企業架構設計師,或是只想大略了解使用 Windows 容器及使用 Microsoft Azure 部署到雲端有何優點的開發部門主管,這篇指南也會很實用。You also might find this guide useful if you are a technical decision maker, such as an enterprise architect or a development lead/director who just wants an overview of the benefits that you can get by using Windows Containers, and by deploying to the cloud when using Microsoft Azure.

    如何使用本指南How to use this guide

    本指南說明了「原因」:吸引您將現有應用程式現代化的誘因,以及將應用程式移往雲端時,使用 Windows 容器所能獲得的具體效益。This guide addresses the "why"-why you might want to modernize your existing applications, and the specific benefits you get from using Windows Containers when you move your apps to the cloud. 本指南前幾個章節中的內容專為想了解概要,但不需要專注在實作及技術性、逐步詳細資料的架構設計師與技術決策者設計而成。The content in the first few chapters of the guide is designed for architects and technical decision makers who want an overview, but who don't need to focus on implementation and technical, step-by-step details.

    本指南的最後一章導入了多個逐步解說,重點放在特定部署案例上。The last chapter of this guide introduces multiple walkthroughs that focus on specific deployment scenarios. 本指南提供較短版本的逐步解說,概述了幾種案例及各案例的優點。This guide offers shorter versions of the walkthroughs, to summarize the scenarios and highlight their benefits. 完整的逐步解說會向下切入安裝及實作細節,並以一組 Wiki 文章的形式發佈到與範本應用程式所在的相同 GitHub 存放區中 (會在下一節中提到)。The full walkthroughs drill down into setup and implementation details, and are published as a set of wiki posts in the same public GitHub repo where related sample apps reside (discussed in the next section). 想要專注在實作細節的開發人員與架構師,可能會對最後一章與 GitHub 上的逐步 Wiki 解說較有興趣。The last chapter and the step-by-step wiki walkthroughs on GitHub will be of more interest to developers and architects who want to focus on implementation details.

    將舊版應用程式現代化的範例應用程式:eShopModernizingSample apps for modernizing legacy apps: eShopModernizing

    GitHub 上的 eShopModernizing 存放庫提供兩個模擬舊版整合型 Web 應用程式的範例應用程式。The eShopModernizing repo on GitHub offers two sample applications that simulate legacy monolithic web applications. 第一個 Web 應用程式採用 ASP.NET MVC 開發而成;第二個 Web 應用程式採用 ASP.NET Web Forms 開發而成;第三個應用程式採用多層式架構 (N-Tier) 搭配 WinForms 用戶端桌面應用程式,加上使用 WCF 服務後端。One web app is developed by using ASP.NET MVC; the second web app is developed by using ASP.NET Web Forms and the third app is an N-Tier app with a WinForms client desktop app consuming a WCF service backend. 所有應用程式都採用傳統的 .NET Framework。All these apps are based on the traditional .NET Framework. 因為這些範例程式理應是要現代化的現有/舊版 .NET Framework 應用程式,所以不會使用 .NET Core 或 ASP.NET Core。These sample apps don't use .NET Core or ASP.NET Core as they are supposed to be existing/legacy .NET Framework applications to be modernized.

    這些範例應用程式都有現代化版程式碼第二個版本,十分容易。These sample apps have a second version, with modernized code, and which are fairly straightforward. 應用程式版本間最主要的差異在於,第二個版本使用了 Windows 容器作為部署選項。The most important difference between the app versions is that the second versions use Windows Containers as the deployment choice. 第二個版本也多了一些附加功能,像是用來管理影像的 Azure 儲存體 Blob、用來管理安全性的 Azure Active Directory,以及用來監視與稽核應用程式的 Azure Application Insights。There also are a few additions to the second versions, like Azure Storage Blobs for managing images, Azure Active Directory for managing security, and Azure Application Insights for monitoring and auditing the applications.

    傳送您的意見反應Send your feedback

    本指南的目的在協助您了解改進及現代化現有 .NET Web 應用程式時的選項。This guide was written to help you understand your options for improving and modernizing existing .NET web applications. 本指南與相關範例應用程式將會不斷更新。The guide and related sample applications are evolving. 歡迎您提供寶貴的意見!Your feedback is welcome! 如果您對本指南可能更有用有意見,請將其發送到dotnet-architecture-ebooks-feedback@service.microsoft.comIf you have comments about how this guide might be more helpful, please send them to dotnet-architecture-ebooks-feedback@service.microsoft.com.