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

Azure Dev Spaces 工作原理How Azure Dev Spaces works

重要

Azure Dev Spaces 即将停用,将于 2023 年 10 月 31 日停止工作。Azure Dev Spaces is being retired and will stop working on October 31, 2023. 请考虑迁移到 Bridge to KubernetesConsider migrating to Bridge to Kubernetes.

开发 Kubernetes 应用程序可能非常困难。Developing a Kubernetes application can be challenging. 需要 Docker 和 Kubernetes 配置文件。You need Docker and Kubernetes configuration files. 你需要确定如何在本地测试应用程序并与其他依赖服务进行交互。You need to figure out how to test your application locally and interact with other dependent services. 你可能需要同时处理多个服务和一组开发人员的开发和测试。You might need to handle developing and testing multiple services at once and with a team of developers.

Azure Dev Spaces 提供多种方法来快速循环访问和调试 Kubernetes 应用程序并与团队进行协作。Azure Dev Spaces provides you with multiple ways to rapidly iterate and debug Kubernetes applications and collaborate with your team. 本文介绍 Azure Dev Spaces 可以执行的操作及其工作原理。This article describes what Azure Dev Spaces can do and how it works.

快速循环访问和调试 Kubernetes 应用程序Rapidly iterate and debug your Kubernetes application

Azure Dev Spaces 降低了在 AKS 群集的上下文中开发、测试和迭代 Kubernetes 应用程序的工作量。Azure Dev Spaces reduces the effort to develop, test, and iterate your Kubernetes application in the context of your AKS cluster. 这种减少的工作量使开发人员可以专注于应用程序的业务逻辑,而不是将其服务配置为在 Kubernetes 中运行。This reduction in effort allows developers to focus on the business logic of their applications and not configuring their services to run in Kubernetes.

Bridge to KubernetesBridge to Kubernetes

通过桥接到 Kubernetes,可以将开发计算机连接到 Kubernetes 群集,这样就可以在开发计算机上运行和调试代码,就像它在群集上运行一样。With Bridge to Kubernetes, you can connect your development computer to your Kubernetes cluster, allowing you to run and debug code on your development computer as if it were running on the cluster. 桥接 Kubernetes 通过在群集上运行一个可充当远程代理来重定向开发计算机和群集之间的流量的 pod,来重定向已连接的群集之间的流量。Bridge to Kubernetes redirects traffic between your connected cluster by running a pod on your cluster that acts as a remote agent to redirect traffic between your development computer and the cluster. 此流量重定向允许开发计算机上的代码和群集中运行的服务进行通信,就像它们位于同一群集中一样。This traffic redirection allows code on your development computer and services running in your cluster to communicate as if they were in the same cluster. 有关将开发计算机连接到 Kubernetes 群集的详细信息,请参阅 桥 To Kubernetes 的工作原理For more information about connecting your development computer to a Kubernetes cluster, see How Bridge to Kubernetes works.

在 AKS 中运行你的代码Run your code in AKS

除了在开发计算机与 AKS 群集之间重定向流量外 Azure Dev Spaces,你还可以配置并快速在 AKS 中运行代码。In addition to redirecting traffic between your development computer and your AKS cluster, with Azure Dev Spaces you can configure and quickly run your code directly in AKS. 通过 Visual Studio、Visual Studio Code 或 Azure Dev Spaces CLI,Azure 开发人员空间会将代码上传到群集,然后生成并运行它。With Visual Studio, Visual Studio Code, or the Azure Dev Spaces CLI, Azure Dev spaces will upload your code to cluster, then build and run it. Azure Dev spaces 还可以智能地同步代码更改,并重新启动服务,以反映所需的更改。Azure Dev spaces can also intelligently sync code changes and restart your service to reflect changes as necessary. 运行代码时,生成日志和 HTTP 跟踪会流式传输回客户端,以便你可以监视进度并诊断任何问题。While running your code, build logs and HTTP traces are streamed back to your client so you can monitor progress and diagnose any issues. 你还可以使用 Azure Dev Spaces 将 Visual Visual Studio Code Studio 中的调试器附加到 Java、Node.js 和 .NET Core 服务中。You can also use Azure Dev Spaces, to attach the debugger in Visual Studio and Visual Studio Code to Java, Node.js, and .NET Core services. 有关详细信息,请参阅 准备 Azure Dev Spaces 项目的工作原理、 使用 Azure Dev Spaces 运行代码的工作原理以及 使用 Azure Dev Spaces 远程调试代码的方式。For more information, see How preparing a project for Azure Dev Spaces works, How running your code with Azure Dev Spaces works, and How remote debugging your code with Azure Dev Spaces works.

团队开发Team development

Azure Dev Spaces 有助于团队在同一 AKS 群集上高效地工作应用程序,而无需中断。Azure Dev Spaces helps teams productively work on their application on the same AKS cluster without being disruptive.

开发共享空间之间的智能路由Intelligent routing between dev spaces

使用 Azure Dev Spaces,团队可以共享运行云本机应用程序的单个 AKS 群集,并创建独立的开发人员空间,团队无需干扰其他开发人员空间即可进行开发、测试和调试。With Azure Dev Spaces, a team can share a single AKS cluster running a cloud-native application and create isolated dev spaces where the team can develop, test, and debug without interfering with the other dev spaces. 应用程序的基线版本在根开发人员空间中运行。A baseline version of the application runs in a root dev space. 然后,团队成员会根据用于开发、测试和调试应用程序更改的根空间创建独立的子开发人员空间。Team members then create independent child dev spaces based on the root space for development, testing, and debugging changes to the application. 通过开发人员空间中的路由功能,子开发人员空间可以在子开发人员空间和父开发人员空间中运行的服务之间路由请求。Through the routing capabilities in Dev Spaces, child dev spaces can route requests between services running in the child dev space and the parent dev space. 使用此路由,开发人员可在从父空间重用依赖服务时运行其自己的服务版本。This routing allows developers to run their own version of a service while reusing dependent services from the parent space. 每个子空间都有其自己的唯一 URL,供其他人进行共享和访问以进行协作。Each child space has its own unique URL, which can be shared and accessed by others for collaboration. 有关路由在 Azure Dev Spaces 中的工作原理的详细信息,请参阅 路由如何与 Azure Dev Spaces 配合工作For more information on how routing works in Azure Dev Spaces, see How routing works with Azure Dev Spaces.

实时测试开放式拉取请求Live testing an open pull request

你还可以将 GitHub 操作与 Azure Dev Spaces 一起使用,以便在合并之前在群集中直接测试对你的应用程序所做的更改。You can also use GitHub Actions with Azure Dev Spaces to test changes to your application in a pull request directly in your cluster before merging. Azure Dev Spaces 可以将应用程序的审阅版本自动部署到群集,使作者和其他团队成员可以查看整个应用程序上下文中的更改。Azure Dev Spaces can automatically deploy a review version of the application to your cluster, allowing the author as well as other team members to review the changes in the context of the entire application. 使用 Azure Dev Spaces 的路由功能,还会将此查看版本的应用程序部署到群集中,而不会影响其他 Dev 空间。Using the routing capabilities of Azure Dev Spaces, this review version of the application is also deployed to your cluster without impacting other dev spaces. 所有这些功能都允许您满怀信心地批准和合并拉取请求。All of these capabilities allow you to confidently approve and merge pull requests. 若要查看 GitHub 操作和 Azure Dev Spaces 的示例,请参阅 Azure Kubernetes 服务 & Github 操作To see an example of GitHub Actions and Azure Dev Spaces, see GitHub Actions & Azure Kubernetes Service.

后续步骤Next steps

若要开始将本地开发计算机连接到 AKS 群集,请参阅 将开发计算机连接到 AKS 群集To get started connecting your local development computer to your AKS cluster, see Connect your development computer to an AKS cluster.