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

Azure 中登陆区域的测试驱动开发Test-driven development for landing zones in Azure

如前面有关 测试驱动开发 (TDD) 用于登陆区域的文章所述,TDD 循环从一个测试开始,该测试验证交付云采用计划所需的特定功能的验收条件。As outlined in the previous article on test-driven development (TDD) for landing zones, TDD cycles begin with a test that validates the acceptance criteria of a specific feature required to deliver the cloud adoption plan. 然后,可以对登陆区域进行测试,以验证是否已满足验收条件。Expanding or refactoring the landing zone can then be tested to validate that the acceptance criteria have been met. 本文概述了 Azure 中的云本机工具链,以自动执行测试驱动的开发周期。This article outlines a cloud-native toolchain in Azure to automate test-driven development cycles.

支持登陆区域 TDD 循环的 Azure 工具Azure tools to support landing zone TDD cycles

Azure 中的测试驱动开发工具

图1: Azure 中的测试驱动开发工具。Figure 1: Test-driven development tools in Azure.

Azure 的工具链监管产品和服务可以轻松集成到测试驱动开发中,以便创建登陆区域。The toolchain of Azure-native governance products and services can be easily integrated into test-driven development for the creation of landing zones. 其中的每个工具都可满足特定目的,使你可以更轻松地开发、测试和部署登陆区域,使其与 TDD 循环保持一致。Each of these tools serves a specific purpose, making it easier to develop, test, and deploy your landing zone in alignment with TDD cycles.

Microsoft 提供的测试和部署模板,以加速 TDDMicrosoft-provided test and deployment templates to accelerate TDD

Microsoft 为管理目的提供了以下示例。The following examples are provided by Microsoft for governance purposes. 每个可用于登陆区域的测试驱动开发周期中的测试或测试系列。Each can be used as a test or series of tests in a test-driven development cycle for landing zones. 以下各节提供了有关每个工具的详细信息:The following sections provide more information on each tool:

  • Azure 蓝图提供各种 蓝图示例,包括用于测试和部署模板的策略。Azure Blueprints provides various blueprint samples, including policies for testing and templates for deployment. 这些蓝图示例可以加快 TDD 周期中的开发、部署和测试工作。These blueprint samples can accelerate development, deployment, and testing efforts in TDD cycles.
  • Azure 策略还包括 内置策略方案,这些方案可用于测试和强制实施对登陆区域完成的完整定义。Azure Policy also includes built-in policy initiatives, which could be used to test and enforce the full definition of done for a landing zone. Azure 策略包含 内置的策略定义 ,这些定义可满足完成定义中的各个验收条件。Azure Policy includes built-in policy definitions that can meet individual acceptance criteria within the definition of done.
  • Azure Graph 包含高级 查询示例,可用于了解在高级测试方案的登录区域内部署工作负载的方式。Azure Graph includes advanced query samples, which can be used to understand how the workloads are deployed within a landing zone for advanced testing scenarios.
  • Azure 快速入门模板 提供了源代码模板,可帮助加速登陆区域和工作负荷部署。Azure quickstart templates provides of source code templates to aid in accelerating landing zone and workload deployment.

上面列出的示例可用作加快 TDD 周期的工具。The examples listed above can be used as tools for accelerating TDD cycles. 它们在以下各节中的管理工具上运行,并允许云平台团队创建自己的源代码和测试。They run on the governance tools in the following sections and allow cloud platform teams to create their own source code and tests.

可加速 TDD 循环的 Azure 调控工具Azure governance tools that can accelerate TDD cycles

Azure 策略:部署或尝试部署与管理策略不同时,azure 策略可以提供自动检测、保护和解决方法。Azure Policy: When deployments or attempted deployments deviate from governance policies, Azure Policy can provide automated detection, protection, and resolution. 但是,Azure 策略还提供了用于在定义完成时测试验收条件的主要机制。But Azure Policy also provides the primary mechanism for testing acceptance criteria in your definition of done. 在 TDD 循环中,可以创建策略定义来测试单个验收条件。In a TDD cycle, a policy definition can be created to test a single acceptance criteria. 同样,可以将所有验收条件添加到分配给整个订阅的策略计划。Likewise, all acceptance criteria can be added to a policy initiative assigned to the entire subscription. 此方法在修改登陆区域之前提供了一种用于红色测试的机制。This approach provides a mechanism for red tests before modifying the landing zone. 登陆区域满足完成的定义后,可以使用它来强制执行测试条件,以避免在未来版本中导致测试失败的代码更改。Once the landing zone meets the definition of done, it can be used to enforce the test criteria to avoid code changes that would cause the test to fail in future releases.

Azure 蓝图: azure 蓝图将策略和其他部署工具分组到可分配到多个登录区域的可重复的包中。Azure Blueprints: Azure blueprint groups policies and other deployment tools into a repeatable package that can be assigned to multiple landing zones. 如果多个采用工作共享了已完成的公共定义(你可能想要随着时间推移进行更新),蓝图就会非常有用。Blueprints prove useful when multiple adoption efforts share common definitions of done, which you may want to update over time. 它还可以帮助进行部署,以便扩展和重构登陆区域。It can also help with deployment during subsequent efforts to expand and refactor landing zones.

Azure 资源关系图:资源关系图提供了一种查询语言,用于基于登陆区域中部署的资产的相关信息创建数据驱动的测试。Azure Resource Graph: Resource Graph provides a query language for creating data-driven tests based on information about the assets deployed within a landing zone. 稍后在采用计划中,此工具还可以根据工作负荷资产与底层云环境之间的交互来定义复杂的测试。Later in the adoption plan, this tool can also define complex tests based on the interactions between workload assets and the underlying cloud environment.

Azure 资源管理器模板:这些模板提供 azure 中部署的任何环境的主要源代码。Azure Resource Manager templates: These templates provide the primary source code for any environment deployed in Azure. 某些第三方工具(如 Terraform)生成其自己的 ARM 模板,然后将其提交到 Azure 资源管理器。Some third-party tools like Terraform generate their own ARM templates, which are then submitted to Azure Resource Manager.

Azure 资源管理器:资源管理器为生成和部署功能提供一致的平台。Azure Resource Manager: Resource Manager provides a consistent platform for build and deploy functions. 此平台可以根据源代码定义部署登陆区域。This platform can deploy landing zones based on source code definitions.

后续步骤Next steps

若要开始重构第一个登陆区域,请评估 基本登陆区域注意事项To begin refactoring your first landing zone, evaluate basic landing zone considerations.