您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

将应用程序迁移到 Azure App Service 和 SQL 数据库Migrate an application to Azure App Service and SQL Database

本文说明了虚构公司 Contoso 如何重构在迁移到 Azure 时在 VMware Vm 上运行的两层 Windows .NET 应用程序。This article demonstrates how the fictional company Contoso refactors a two-tier Windows .NET application that's running on VMware VMs as part of a migration to Azure. Contoso 团队将应用程序前端虚拟机 (VM) 迁移到 Azure App Service web 应用,并将应用程序数据库迁移到 Azure SQL Database。The Contoso team migrates the application front-end virtual machine (VM) to an Azure App Service web app and the application database to Azure SQL Database.

本示例中使用的 SmartHotel360 应用程序作为开放源代码提供。The SmartHotel360 application that we use in this example is provided as open source. 如果要将其用于自己的测试目的,可以从 GitHub下载。If you want to use it for your own testing purposes, you can download it from GitHub.

业务驱动因素Business drivers

Contoso IT 领导团队与其业务合作伙伴密切协作,以了解合作伙伴希望在本次迁移中实现的目标:The Contoso IT leadership team has worked closely with business partners to understand what they want to achieve with this migration:

  • 解决业务增长。Address business growth. Contoso 正在不断增长,其本地系统和基础结构有压力。Contoso is growing, and there is pressure on their on-premises systems and infrastructure.
  • 提高效率。Increase efficiency. Contoso 需要删除不必要的过程,并简化开发人员和用户的过程。Contoso needs to remove unnecessary procedures and streamline processes for developers and users. 业务要求 IT 反应迅速,不浪费时间金钱,从而更快满足客户需求。The business needs IT to be fast and not waste time or money, thus delivering faster on customer requirements.
  • 提高灵活性。Increase agility. 为了在全球经济中实现成功,Contoso 需要更好地响应业务需求。To enable their success in a global economy, Contoso IT needs to be more responsive to the needs of the business. 它必须能够更快地响应 marketplace 中的更改。It must be able to react more quickly to changes in the marketplace. 它不能以这种方式获取或成为企业阻止。IT must not get in the way or become a business blocker.
  • 纵向.Scale. 随着业务成功发展,Contoso IT 必须提供能够同步成长的系统。As the business grows successfully, Contoso IT must provide systems that are able to grow at the same pace.
  • 降低成本。Reduce costs. Contoso 希望将许可成本降至最低。Contoso wants to minimize licensing costs.

迁移目标Migration goals

为了帮助确定最佳迁移方法,Contoso 云团队固定了以下目标:To help determine the best migration method, the Contoso cloud team pinned down the following goals:

要求Requirements 详细信息Details
应用程序Application Azure 中的应用程序将保持关键,因为目前在本地。The application in Azure will remain as critical as it is today on-premises.

它应当具有与当前在 VMware 中的性能相同的性能。It should have the same performance capabilities as it currently does in VMware.

团队不希望在应用程序中投入投资。The team doesn't want to invest in the application. 目前,管理员只需将应用程序安全地移到云中。For now, admins will simply move the application safely to the cloud.

团队想要停止支持的 Windows Server 2008 R2,应用程序当前运行在该服务器上。The team wants to stop supporting Windows Server 2008 R2, which the application currently runs on.

此团队还想要从 SQL Server 2008 R2 移动到现代平台即服务 (PaaS) 数据库,这将最大程度地减少管理需求。The team also wants to move away from SQL Server 2008 R2 to a modern platform as a service (PaaS) database, which will minimize the need for management.

Contoso 希望尽可能利用其在 SQL Server 许可和软件保障方面的投资。Contoso wants to take advantage of its investment in SQL Server licensing and Software Assurance where possible.

此外,Contoso 还希望减少 Web 层上的单一故障点。In addition, Contoso wants to mitigate the single point of failure on the web tier.
限制Limitations 应用程序包含 ASP.NET 应用程序和 Windows Communication Foundation (WCF) 服务在同一 VM 上运行。The application consists of an ASP.NET application and a Windows Communication Foundation (WCF) service running on the same VM. 他们希望使用 Azure App Service 将这些组件分散到两个 web 应用中。They want to spread these components across two web apps using the Azure App Service.
AzureAzure Contoso 想要将应用程序移动到 Azure,但不希望在 Vm 上运行它。Contoso wants to move the application to Azure, but they don't want to run it on VMs. Contoso 希望为 Web 层和数据层使用 Azure PaaS 服务。Contoso wants to use Azure PaaS services for both the web and data tiers.
DevOpsDevOps Contoso 想要迁移到 DevOps 模型,该模型使用 Azure DevOps 生成和发布管道。Contoso wants to move to a DevOps model that uses Azure DevOps for their builds and release pipelines.

解决方案设计Solution design

在固定其目标和需求后,Contoso 设计和审查部署解决方案。After pinning down their goals and requirements, Contoso designs and reviews a deployment solution. 它们还确定了迁移过程,包括用于迁移的 Azure 服务。They also identify the migration process, including the Azure services that they'll use for the migration.

当前应用程序Current application

  • SmartHotel360 本地应用程序跨两个 Vm 和进行分层 WEBVM SQLVMThe SmartHotel360 on-premises application is tiered across two VMs, WEBVM and SQLVM.
  • Vm 位于 VMware ESXi host contosohost1.contoso.com 版本6.5 上。The VMs are located on VMware ESXi host contosohost1.contoso.com version 6.5.
  • VMware 环境由在虚拟机上运行的 vCenter Server 6.5 (vcenter.contoso.com) 进行管理。The VMware environment is managed by vCenter Server 6.5 (vcenter.contoso.com), which runs on a VM.
  • Contoso 有一个本地数据中心 (contoso-datacenter),其中包含一个本地域控制器 (contosodc1)。Contoso has an on-premises datacenter (contoso-datacenter), with an on-premises domain controller (contosodc1).
  • 迁移完成后,Contoso 数据中心的本地 VM 将停止使用。The on-premises VMs in the Contoso datacenter will be decommissioned after the migration is done.

建议的解决方案Proposed solution

  • 对于应用程序的数据库层,Contoso 比较 Azure SQL 数据库到 SQL Server,方法是参阅 功能比较: AZURE Sql 数据库和 AZURE sql 托管实例For the database tier of the application, Contoso compared Azure SQL Database to SQL Server by referring to Features comparison: Azure SQL Database and Azure SQL Managed Instance. Contoso 决定使用 Azure SQL 数据库,原因如下:Contoso decided to use Azure SQL Database for a few reasons:
    • Azure SQL 数据库是托管关系数据库服务。Azure SQL Database is a managed relational database service. 它在多个服务级别提供可预测的性能,几乎不需要管理。It delivers predictable performance at multiple service levels, with near-zero administration. 优点包括在不停机的情况下实现动态可伸缩性、内置的智能优化以及全局可伸缩性和可用性。Advantages include dynamic scalability with no downtime, built-in intelligent optimization, and global scalability and availability.
    • Contoso 可以使用轻型数据迁移助手来评估将本地数据库迁移到 Azure SQL。Contoso can use the lightweight Data Migration Assistant to assess the on-premises database migration to Azure SQL.
    • Contoso 可以使用 Azure 数据库迁移服务将本地数据库迁移到 Azure SQL。Contoso can use Azure Database Migration Service to migrate the on-premises database to Azure SQL.
    • 对于软件保障,Contoso 可以通过使用 SQL Server 的 Azure 混合权益,与 SQL 数据库中数据库的折扣率交换现有许可证。With Software Assurance, Contoso can exchange existing licenses for discounted rates on a database in SQL Database by using the Azure Hybrid Benefit for SQL Server. 此方法可以节省高达30% 的成本。This approach could provide a cost saving of up to 30 percent.
    • SQL 数据库提供安全功能,例如 Always Encrypted、动态数据掩码、行级别安全性和 SQL 威胁检测。SQL Database provides security features such as Always Encrypted, dynamic data masking, row-level security, and SQL threat detection.
  • 对于应用程序的 web 层,Contoso 已决定使用 Azure App Service。For the application web tier, Contoso has decided to use Azure App Service. 使用此 PaaS 服务,只需进行少量的配置更改便可部署应用程序。This PaaS service enables them to deploy the application with just a few configuration changes. Contoso 将使用 Visual Studio 进行更改,并部署两个 web 应用,一个用于网站,另一个用于 WCF 服务。Contoso will use Visual Studio to make the change, and they'll deploy two web apps, one for the website and one for the WCF service.
  • 为了满足 DevOps 管道的要求,Contoso 将使用 Azure DevOps 进行源代码管理,并使用 Git 存储库。To meet requirements for a DevOps pipeline, Contoso will use Azure DevOps for source code management with Git repos. 他们将使用自动生成和发布生成代码并将其部署到 Azure App Service。They'll use automated builds and release to build the code and deploy it to the Azure App Service.

解决方案评审Solution review

Contoso 通过结合使用 "优点" 和 "缺点" 列表来评估其建议的设计,如下表所示:Contoso evaluates their proposed design by putting together a pros and cons list, as shown in the following table:

注意事项Consideration 详细信息Details
优点Pros SmartHotel360 应用程序代码不需要更改即可迁移到 Azure。The SmartHotel360 application code doesn't require changes for migration to Azure.

Contoso 可以通过对 SQL Server 和 Windows Server 使用 Azure 混合权益,充分利用其对软件保障的投资。Contoso can take advantage of their investment in Software Assurance by using the Azure Hybrid Benefit for both SQL Server and Windows Server.

迁移后,不需要支持 Windows Server 2008 R2。After the migration, Windows Server 2008 R2 won't need to be supported. 有关详细信息,请参阅 Microsoft 生命周期策略For more information, see the Microsoft Lifecycle Policy.

Contoso 可以配置具有多个实例的应用程序的 web 层,使 web 层不再是单一故障点。Contoso can configure the web tier of the application with multiple instances, so that the web tier is no longer a single point of failure.

数据库不再依赖于老化的 SQL Server 2008 R2。The database will no longer depend on the aging SQL Server 2008 R2.

SQL 数据库支持相关技术要求。SQL Database supports the technical requirements. Contoso 使用数据迁移助手评估了本地数据库,并发现它是兼容的。Contoso assessed the on-premises database by using Data Migration Assistant and found that it's compatible.

Azure SQL 数据库具有内置的容错能力,Contoso 无需设置。Azure SQL Database has built-in fault tolerance that Contoso doesn't have to set up. 这将确保数据层不再是单一故障转移点。This ensures that the data tier is no longer a single point of failover.

如果 Contoso 使用 Azure 数据库迁移服务来迁移数据库,它将具有可用于大规模迁移数据库的基础结构。If Contoso uses Azure Database Migration Service to migrate their database, it will have the infrastructure ready for migrating databases at scale.
缺点Cons 对于每个 web 应用,Azure App Service 仅支持一个应用程序部署。Azure App Service supports only one application deployment for each web app. 这意味着必须预配两个 web 应用,一个用于网站,另一个用于 WCF 服务。This means that two web apps must be provisioned, one for the website and one for the WCF service.

建议的体系结构Proposed architecture


迁移过程Migration process

  1. Contoso 预配 Azure SQL 托管实例,然后使用 Azure 数据库迁移服务将 SmartHotel360 数据库迁移到该实例。Contoso provisions an Azure SQL managed instance and then migrates the SmartHotel360 database to it by using Azure Database Migration Service.

  2. Contoso 预配和配置 web 应用,并向其部署 SmartHotel360 应用程序。Contoso provisions and configures web apps, and deploys the SmartHotel360 application to them.


Azure 服务Azure services

服务Service 说明Description 成本Cost
Azure 应用服务迁移助手Azure App Service Migration Assistant 一个免费且简单的路径,可无缝地将 .NET web 应用程序从本地迁移到云,而无需更改代码。A free and simple path to seamlessly migrate .NET web applications from on-premises to the cloud with minimal to no code changes. 它是免费的可下载工具。It's a downloadable tool, free of charge.
Data Migration AssistantData Migration Assistant Contoso 将使用数据迁移助手来评估并检测可能会影响 Azure 中的数据库功能的兼容性问题。Contoso will use Data Migration Assistant to assess and detect compatibility issues that might affect database functionality in Azure. 数据迁移助手评估 SQL 源和目标之间的功能奇偶校验,并建议改进性能和可靠性。Data Migration Assistant assesses feature parity between SQL sources and targets, and it recommends performance and reliability improvements. 它是免费的可下载工具。It's a downloadable tool, free of charge.
Azure 数据库迁移服务Azure Database Migration Service Azure 数据库迁移服务实现了从多个数据库源到 Azure 数据平台的无缝迁移,且停机时间最短。Azure Database Migration Service enables seamless migration from multiple database sources to Azure data platforms with minimal downtime. 了解支持的区域数据库迁移服务定价Learn about supported regions and Database Migration Service pricing.
Azure SQL 数据库Azure SQL Database 一个智能的、完全托管的关系型云数据库服务。An intelligent, fully managed relational cloud database service. 成本基于功能、吞吐量和大小。Cost is based on features, throughput, and size. 了解详细信息Learn more.
Azure 应用服务Azure App Service 有助于创建使用完全托管平台的功能强大的云应用程序。Helps create powerful cloud applications that use a fully managed platform. 定价基于大小、位置和使用期限。Pricing is based on size, location, and usage duration. 了解详细信息Learn more.
Azure DevOpsAzure DevOps 为应用程序开发 (CI/CD) 管道提供持续集成和持续部署。Provides a continuous integration and continuous deployment (CI/CD) pipeline for application development. 该管道从 Git 存储库开始,用于管理应用程序代码、用于生成包的生成系统和其他生成项目,以及用于在开发、测试和生产环境中部署更改的发布管理系统。The pipeline starts with a Git repository for managing application code, a build system for producing packages and other build artifacts, and a release management system to deploy changes in dev, test, and production environments.


若要运行此方案,Contoso 必须满足以下先决条件:To run this scenario, Contoso must meet the following prerequisites:

要求Requirements 详细信息Details
Azure 订阅Azure subscription 在前面的系列文章中,Contoso 已创建订阅。Contoso created subscriptions earlier in this article series. 如果还没有 Azure 订阅,可以创建一个免费帐户If you don't have an Azure subscription, create a free account.

如果创建的是免费帐户,则你是自己的订阅的管理员,可以执行所有操作。If you create a free account, you're the administrator of your subscription and can perform all actions.

如果你使用现有订阅并且不是管理员,则需要请求管理员为你分配“所有者”或“参与者”权限。If you use an existing subscription and you're not the administrator, you need to work with the admin to assign you Owner or Contributor permissions.
Azure 基础结构Azure infrastructure Contoso 按照用于迁移的 Azure 基础结构中所述设置其 Azure 基础结构。Contoso set up their Azure infrastructure as described in Azure infrastructure for migration.

方案步骤Scenario steps

Contoso 按如下方式运行迁移:Here's how Contoso will run the migration:

  • 步骤1:评估和迁移 web 应用。Step 1: Assess and migrate the web apps.. Contoso 使用 Azure App Service 迁移助手 工具来运行迁移前兼容性检查,并将其 web 应用迁移到 Azure App Service。Contoso uses the Azure App Service Migration Assistant tool to run pre-migration compatibility checks and migrate their web apps to Azure App Service.
  • 步骤2:在 AZURE SQL 数据库中预配数据库Step 2: Provision a database in Azure SQL Database. Contoso 预配 Azure SQL 数据库实例。Contoso provisions an Azure SQL Database instance. 将应用程序网站迁移到 Azure 后,WCF 服务 web 应用将指向此实例。After the application website is migrated to Azure, the WCF service web app will point to this instance.
  • 步骤3:评估数据库Step 3: Assess the database. Contoso 使用数据迁移助手评估要迁移的数据库,然后通过 Azure 数据库迁移服务进行迁移。Contoso assesses the database for migration by using Data Migration Assistant and then migrates it via Azure Database Migration Service.
  • 步骤4:设置 Azure DevOpsStep 4: Set up Azure DevOps. Contoso 创建新的 Azure DevOps 项目,并导入 Git 存储库。Contoso creates a new Azure DevOps project, and imports the Git repo.
  • 步骤5:配置连接字符串Step 5: Configure connection strings. Contoso 将配置连接字符串,这样使 Web 层 Web 应用、WCF 服务 Web 应用和 SQL 实例能够进行通信。Contoso configures connection strings so that the web tier web app, the WCF service web app, and the SQL instance can communicate.
  • 步骤6:在 Azure DevOps 中设置生成和发布管道Step 6: Set up build and release pipelines in Azure DevOps. 作为最后一步,Contoso 在 Azure DevOps 中设置生成和发布管道,以创建应用程序,然后将其部署到两个单独的 web 应用。As a final step, Contoso sets up build and release pipelines in Azure DevOps to create the application, and then deploys them to two separate web apps.

步骤1:评估和迁移 web 应用Step 1: Assess and migrate the web apps

Contoso 管理员使用 Azure App Service 迁移助手 工具评估和迁移其 web 应用。Contoso admins assess and migrate their web app using the Azure App Service Migration Assistant tool. 在此过程中,他们使用将 ASP.NET 应用迁移到 Azure 学习路径 ,作为指导。They use the Migrate ASP.NET Apps to Azure learning path as a guide during the process. 管理员执行以下操作:The admins perform these actions:

  • 他们使用 Azure 应用服务迁移评估 工具评估其 web 应用之间的任何依赖关系,并确定其本地 web 应用与 Azure App Service 支持的内容之间是否存在任何不兼容问题。They use the Azure App Service Migration Assessment tool to evaluate any dependencies between their web apps and to determine if there are any incompatibilities between their on-premises web apps and what's supported on Azure App Service.

  • 它们下载 Azure App Service 迁移助手并登录到 Azure 帐户。They download the Azure App Service Migration Assistant and sign in to their Azure account.

  • 它们选择订阅、资源组和网站的域名。They choose a subscription, a resource group, and the website's domain name.

步骤2:在 Azure SQL 数据库中预配数据库Step 2: Provision a database in Azure SQL Database

  1. Contoso 管理员决定创建 Azure SQL 数据库实例。Contoso admins decide to create an Azure SQL Database instance.

    显示 SQL 数据库链接的屏幕截图。

  2. 它们指定数据库名称以匹配 SmartHotel.Registration 在本地 VM 上运行的数据库。They specify a database name to match the database, SmartHotel.Registration, that's running on the on-premises VM. 将数据库置于 ContosoRG 资源组中。They place the database in the ContosoRG resource group. 这是用于 Azure 中的生产资源的资源组。This is the resource group they use for production resources in Azure.

    显示 SQL 数据库实例详细信息的屏幕截图。

  3. 它们在主要区域中设置新的 SQL Server 实例 smarthotel-eus2They set up a new SQL Server instance, sql-smarthotel-eus2, in the primary region.

    新 SQL Server 实例的屏幕截图。

  4. 设置定价层以匹配其服务器和数据库需求。They set the pricing tier to match their server and database needs. 选择使用 Azure 混合权益来节省资金,因为他们已有一个 SQL Server 许可证。And they select to save money with Azure Hybrid Benefit because they already have a SQL Server license.

  5. 对于大小调整,它们使用基于 vCore 的购买,并为其预期要求设置限制。For sizing, they use vCore-based purchasing and set the limits for their expected requirements.

    VCore 大小调整要求的屏幕截图。

  6. 它们将创建数据库实例。They create the database instance.

    创建 SQL 数据库实例的屏幕截图。

  7. 它们会打开数据库并记下在使用数据迁移助手进行迁移时所需的详细信息。They open the database and note the details they'll need when they use Data Migration Assistant for migration.


需要更多帮助?Need more help?

步骤3:评估数据库Step 3: Assess the database

Contoso 管理员使用数据迁移助手评估数据库,然后使用 Azure 数据库迁移服务来迁移数据库,方法是参阅分步 迁移教程Contoso admins assess the database by using Data Migration Assistant and then migrate it by using Azure Database Migration Service by referring to the step-by-step migration tutorial. 它们可以联机、脱机和混合 (预览) 迁移。They can perform online, offline, and hybrid (preview) migrations.

简而言之,管理员执行以下操作:In brief, the admins do the following:

  • 它们使用数据迁移助手发现和解决任何数据库迁移问题。They use Data Migration Assistant to discover and resolve any database migration issues.
  • 它们使用连接到虚拟网络的高级 SKU 创建 Azure 数据库迁移服务实例。They create an Azure Database Migration Service instance with a Premium SKU that's connected to the virtual network.
  • 它们确保实例可以通过虚拟网络访问远程 SQL Server。They ensure that the instance can access the remote SQL Server via the virtual network. 这就需要确保所有传入端口都允许从 Azure SQL Server 虚拟网络级别、网络 VPN 和承载 SQL Server 的计算机。This entails ensuring that all incoming ports are allowed from Azure to SQL Server at the virtual network level, the network VPN, and the machine that hosts SQL Server.
  • 它们配置实例:They configure the instance:
    • 创建迁移项目。Create a migration project.
    • 添加源 (本地数据库) 。Add a source (on-premises database).
    • 选择一个目标。Select a target.
    • 选择要迁移的数据库。Select the databases to migrate.
    • 配置高级设置。Configure advanced settings.
    • 开始复制。Start the replication.
    • 解决任何错误。Resolve any errors.
    • 执行最终切换。Perform the final cutover.

步骤 4:设置 Azure DevOpsStep 4: Set up Azure DevOps

Contoso 需要为应用程序构建 DevOps 基础结构和管道。Contoso needs to build the DevOps infrastructure and pipelines for the application. 为此,Contoso 管理员需创建新的 DevOps 项目、导入代码,然后设置生成和发布管道。To do this, Contoso admins create a new DevOps project, import the code, and then set up build and release pipelines.

  1. 在 Contoso Azure DevOps 帐户中创建一个新项目 ContosoSmartHotelRefactor,然后选择 Git 进行版本控制。In the Contoso Azure DevOps account, they create a new project, ContosoSmartHotelRefactor, and then select Git for version control.

    在 Azure DevOps 中创建新项目的屏幕截图。

  2. 它们导入当前保存其应用程序代码的 Git 存储库。They import the Git repo that currently holds their application code. 它们从 公共 GitHub 存储库下载。They download it from the public GitHub repository.

    "导入 Git 存储库" 窗格的屏幕截图。

  3. 它们将 Visual Studio 连接到存储库,然后使用团队资源管理器将代码克隆到开发人员计算机。They connect Visual Studio to the repo and then clone the code to the developer machine by using Team Explorer.

    "连接到项目" 窗格的屏幕截图。

  4. 它们将为应用程序打开解决方案文件。They open the solution file for the application. Web 应用和 WCF 服务在文件中具有不同的项目。The web app and the WCF service have separate projects within the file.

    列出 web 应用和 WCF 服务项目的解决方案资源管理器屏幕截图。

步骤 5:配置连接字符串Step 5: Configure connection strings

Contoso 管理员确保 web 应用和数据库可以互相通信。The Contoso admins make sure that the web apps and database can communicate with each other. 为此,他们在代码和 Web 应用中配置连接字符串。To do this, they configure connection strings in the code and in the web apps.

  1. 在 WCF 服务的 web 应用中,在 " SHWCF-EUS2 设置 > " "应用程序设置" 下,添加名为 DefaultConnection 的新连接字符串。In the web app for the WCF service, SHWCF-EUS2, under Settings > Application settings, they add a new connection string named DefaultConnection.

  2. 它们从 SmartHotel-Registration 数据库中提取连接字符串,然后用正确的凭据对其进行更新。They pull the connection string from the SmartHotel-Registration database and then update it with the correct credentials.

    "连接字符串设置" 窗格的屏幕截图。

  3. 在 Visual Studio 中,管理员 SmartHotel.Registration.wcf 从解决方案文件中打开项目。In Visual Studio, the admins open the SmartHotel.Registration.wcf project from the solution file. 在项目中,它们 connectionStrings web.config 用连接字符串更新文件的部分。In the project, they update the connectionStrings section of the web.config file with the connection string.

    SmartHotel 项目中 web.config 文件的 connectionStrings 部分的屏幕截图。

  4. 它们将 client 文件的部分更改 web.configSmartHotel.Registration.Web ,以指向 WCF 服务的新位置。They change the client section of the web.config file for SmartHotel.Registration.Web to point to the new location of the WCF service. 这是承载服务终结点的 WCF web 应用程序的 URL。This is the URL of the WCF web app that hosts the service endpoint.

    SmartHotel 项目中 web.config 文件的客户端部分的屏幕截图。

  5. 现在更改了代码,管理员将使用 Visual Studio 中的团队资源管理器提交和同步这些更改。With the code changes now in place, the admins commit and sync them by using Team Explorer in Visual Studio.

步骤 6:在 Azure DevOps 中设置生成和发布管道Step 6: Set up build and release pipelines in Azure DevOps

Contoso 管理员现在将 Azure DevOps 配置为执行生成和发布过程。The Contoso admins now configure Azure DevOps to perform the build and release process.

  1. 在 Azure DevOps 中,他们选择 "构建" 和 "发布" > 新管道In Azure DevOps, they select Build and release > New pipeline.

    Azure DevOps 中的 "新建管道" 链接的屏幕截图。

  2. 它们选择 Azure Repos Git ,然后在 " 存储库 " 下拉列表中选择相关存储库。They select Azure Repos Git and, in the Repository drop-down list, they select the relevant repo.

    "Azure Repos Git" 按钮和所选存储库的屏幕截图。

  3. 在 " 选择模板" 下,它们会为其生成选择 ASP.NET 模板。Under Select a template, they select the ASP.NET template for their build.

    用于选择 ASP.NET 模板的 "选择模板" 窗格的屏幕截图。

  4. 它们使用名称 ContosoSmartHotelRefactor-ASP.NET-CI 进行生成,然后选择 " & 保存",以启动第一个生成。They use the name ContosoSmartHotelRefactor-ASP.NET-CI for the build and then select Save & queue, which kicks off the first build.

    生成的 "保存并排队" 按钮的屏幕截图。

  5. 他们选择生成号以监视进程。They select the build number to watch the process. 完成后,管理员可以看到过程反馈,并选择 项目 以查看生成结果。After it's finished, the admins can see the process feedback, and they select Artifacts to review the build results.

    "生成" 页和 "项目" 链接的屏幕截图,用于查看生成结果。

    " 项目资源管理器 " 窗格随即打开, 放置 文件夹显示生成结果。The Artifacts explorer pane opens, and the drop folder displays the build results.

    • 这两个 .zip 文件是包含应用程序的包。The two .zip files are the packages that contain the applications.
    • 这些 .zip 文件在发布管道中使用,以便部署到 Azure App Service。These .zip files are used in the release pipeline for deployment to Azure App Service.

    "项目资源管理器" 窗格的屏幕截图。

  6. 它们选择 发布 > + 新管道They select Releases > + New pipeline.


  7. 选择 Azure 应用服务的部署模板。They select the deployment template for Azure App Service.

    Azure App Service 部署模板的屏幕截图。

  8. 它们将发布管道命名为 ContosoSmartHotel360Refactor ,然后在 " 阶段名称 " 框中,将 SHWCF 指定为 WCF web 应用的名称。They name the release pipeline ContosoSmartHotel360Refactor and, in the Stage name box, specify SHWCF-EUS2 as the name of the WCF web app.

    WCF web 应用的阶段名称屏幕截图。

  9. 在此阶段中,选择“1 个作业,1 个任务”,以配置 WCF 服务的部署。Under the stages, they select 1 job, 1 task to configure deployment of the WCF service.

    "1 作业,1个任务" 选项的屏幕截图。

  10. 它们将验证是否已选择并授权订阅,然后选择 应用服务名称They verify that the subscription is selected and authorized, and then they select the app service name.


  11. 在管道 > 项目 上,它们选择 " + 添加项目",然后选择使用 ContosoSmarthotel360Refactor 管道生成。On the pipeline > Artifacts, they select + Add an artifact, then select to build with the ContosoSmarthotel360Refactor pipeline.

    "添加项目" 窗格上的 "生成" 按钮的屏幕截图。

  12. 若要启用连续部署触发器,管理员需要选择项目上的闪电形图标。To enable the continuous deployment trigger, the admins select the lightning bolt icon on the artifact.


  13. 它们将持续部署触发器设置为 " 已启用"。They set the continuous deployment trigger to Enabled.

    显示 "持续部署触发器" 设置为 "已启用" 的屏幕截图。

  14. 管理员返回到阶段 1 作业,1个任务, 然后选择 " 部署 Azure App Service"。The admins go back to the stage 1 job, 1 task and then select Deploy Azure App Service.

    选择 "部署 Azure App Service" 的选项的屏幕截图。

  15. 在 " 选择文件或文件夹" 中,展开 放置 文件夹,选择在生成过程中创建的 SmartHotel.Registration.Wcf.zip 文件,然后选择 " 保存"。In Select a file or folder, they expand the drop folder, select the SmartHotel.Registration.Wcf.zip file that was created during the build, and then select Save.

    用于选择 WCF 文件的 "选择文件或文件夹" 窗格的屏幕截图。

  16. 它们选择 "管道 > 阶段",然后选择 " + 添加",添加的环境 SHWEB-EUS2They select Pipeline > Stages, and then select + Add to add an environment for SHWEB-EUS2. 选择另一个 Azure 应用服务部署。They select another Azure App Service deployment.

    用于添加环境的 "1 作业,1个任务" 链接的屏幕截图。

  17. 它们重复此过程以将 SmartHotel.Registration.Web.zip 文件发布到正确的 web 应用,然后选择 " 保存"。They repeat the process to publish the SmartHotel.Registration.Web.zip file to the correct web app, and then select Save.

    用于选择 WEB 文件的 "选择文件或文件夹" 窗格的屏幕截图。

    此时将显示 release 管道,如下所示:The release pipeline is displayed, as shown here:


  18. 它们返回 " 生成",选择 " 触发器",然后选中 " 启用持续集成 " 复选框。They go back to Build, select Triggers, and then select the Enable continuous integration check box. 此操作启用管道,以便在将更改提交到代码时,会发生完整的生成和发布。This action enables the pipeline so that when changes are committed to the code, the full build and release occur.

    显示 "启用持续集成" 复选框的屏幕截图。

  19. 它们选择 " 保存 & 队列 " 以运行完整管道。They select Save & queue to run the full pipeline. 触发新的生成,该生成又会创建应用程序的第一个版本到 Azure App Service。A new build is triggered, which in turn creates the first release of the application to the Azure App Service.

    "保存 & 队列" 按钮的屏幕截图。

  20. Contoso 管理员可以从 Azure DevOps 中按照生成和发布管道流程进行操作。Contoso admins can follow the build and release pipeline process from Azure DevOps. 生成完成后,版本将启动。After the build finishes, the release starts.


  21. 管道完成后,这两个站点均已部署,并且应用程序已启动并联机运行。After the pipeline finishes, both sites have been deployed, and the application is up and running online.


    应用程序已成功迁移到 Azure。The application has been successfully migrated to Azure.

迁移后的清理Clean up after migration

迁移后,Contoso 完成这些清理步骤:After migration, Contoso completes these cleanup steps:

  • 从 vCenter 库存中删除本地 VM。They remove the on-premises VMs from the vCenter inventory.
  • 它们将 Vm 从本地备份作业中删除。They remove the VMs from the local backup jobs.
  • 它们将更新其内部文档以显示 SmartHotel360 应用程序的新位置。They update their internal documentation to show the new locations for the SmartHotel360 application. 该文档显示在 Azure SQL 数据库中运行的数据库,以及在两个 web 应用中运行的前端。The documentation shows the database as running in Azure SQL Database and the front end as running in two web apps.
  • 它们查看与已解除授权的 Vm 交互的任何资源,并更新任何相关的设置或文档,以反映新的配置。They review any resources that interact with the decommissioned VMs, and they update any relevant settings or documentation to reflect the new configuration.

查看部署Review the deployment

由于资源现在已迁移到 Azure,因此 Contoso 需要完全操作并帮助保护其新基础结构。With the resources now migrated to Azure, Contoso needs to fully operationalize and help secure their new infrastructure.


  • Contoso 有助于确保其新 SmartHotel-Registration 数据库是安全的。Contoso helps ensure that their new SmartHotel-Registration database is secure. 了解详细信息Learn more.
  • 具体而言,Contoso 会将 web 应用更新为使用带有证书的 SSL。In particular, Contoso updates the web apps to use SSL with certificates.


  • Contoso 团队查看 Azure SQL 数据库的备份要求。The Contoso team reviews the backup requirements for the Azure SQL Database. 了解详细信息Learn more.
  • 还介绍了如何管理 SQL 数据库备份和还原。They also learn about managing SQL Database backups and restores. 了解有关 自动备份的详细信息。Learn more about automatic backups.
  • 它们考虑实施故障转移组,为数据库提供区域故障转移。They consider implementing failover groups to provide regional failover for the database. 了解详细信息Learn more.
  • 为实现复原能力,它们会考虑在主要区域中部署 web 应用 (East US 2) , () 的次要区域 Central USFor resilience, they consider deploying the web app in the main region (East US 2) and the secondary region (Central US). 团队可以配置流量管理器,以确保在发生区域性故障时进行故障转移。The team could configure Traffic Manager to ensure failover during regional outages.

许可和成本优化Licensing and cost optimization

  • 部署所有资源后,Contoso 会根据其 基础结构规划分配 Azure 标记。After all resources are deployed, Contoso assigns Azure tags based on their infrastructure planning.
  • 所有许可成本都包括在 Contoso 使用的 PaaS 服务的成本中。All licensing is built into the cost of the PaaS services that Contoso is consuming. 此成本从企业协议中扣减。This cost is deducted from the Enterprise Agreement.
  • Contoso 将使用 Azure 成本管理和计费 来确保他们在其 IT 领导地位的范围内保持在预算内。Contoso will use Azure Cost Management and Billing to ensure that they stay within the budgets established by their IT leadership.


在本文中,Contoso 通过将应用程序前端 VM 迁移到两个 Azure App Service web 应用,在 Azure 中重构了 SmartHotel360 应用程序。In this article, Contoso refactored the SmartHotel360 application in Azure by migrating the application front-end VM to two Azure App Service web apps. 应用程序数据库已迁移到 Azure SQL Database。The application database was migrated to Azure SQL Database.