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

Visual Studio Code 如何处理 Azure Dev SpacesHow Visual Studio Code works with Azure Dev Spaces

重要

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.

您可以使用 Visual Studio Code 和 Azure Dev Spaces 扩展 通过 Azure Dev Spaces 准备、运行和调试您的服务。You can use Visual Studio Code and the Azure Dev Spaces extension to prepare, run, and debug your services with Azure Dev Spaces. 通过 Visual Studio Code 和 Azure Dev Spaces 扩展,可以:With Visual Studio Code and the Azure Dev Spaces extension, you can:

  • 为在 AKS 中运行和调试服务生成资产Generate assets for running and debugging services in AKS
  • 在开发环境中运行 Java、Node.js 和 .NET Core 服务Run your Java, Node.js, and .NET Core services in a dev space
  • 直接调试在开发人员空间中运行的 Java、Node.js 和 .NET Core 服务Directly debug your Java, Node.js, and .NET Core services running in a dev space

生成资产Generate assets

Visual Studio Code 和 Azure Dev Spaces 扩展为你的项目生成以下资产:Visual Studio Code and the Azure Dev Spaces extension generate the following assets for your project:

  • 使用 Maven、Node.js 应用程序和 .NET Core 应用程序的 Java 应用程序的 dockerfileDockerfiles for Java applications using Maven, Node.js applications, and .NET Core applications
  • 使用 Dockerfile 的几乎任何语言的 Helm 图Helm charts for almost any language with a Dockerfile
  • 一个 azds.yaml 文件,该文件是项目的Azure Dev Spaces 配置文件An azds.yaml file, which is the Azure Dev Spaces configuration file for your project
  • 一个 .vscode 文件夹,其中包含使用 Maven、Node.js 应用程序和 .Net Core 应用程序的 Java 应用程序的项目 Visual Studio Code 启动配置A .vscode folder with the Visual Studio Code launch configuration of your project for Java applications using Maven, Node.js applications, and .NET Core applications

Dockerfile、Helm 图表和 azds.yaml 文件是运行时生成的相同资产 azds prepThe Dockerfile, Helm chart, and azds.yaml files are the same assets generated when running azds prep. 也可以在 Visual Studio code 之外使用这些文件在 AKS 中运行项目,如运行 azds upThose files can also be used outside of Visual Studio code to run your project in AKS, such as running azds up. .vscode 文件夹仅由 Visual Studio code 用来在 Visual Studio Code 的 AKS 中运行项目。The .vscode folder is only used by Visual Studio code to run your project in AKS from Visual Studio Code.

在 AKS 中运行你的服务Run your service in AKS

为项目生成资产后,可以从 Visual Studio Code 在现有的开发环境中运行 Java、Node.js 和 .NET Core 服务。After you generate the assets for your project, you can run your Java, Node.js, and .NET Core services in an existing dev space from Visual Studio Code. 在 Visual Studio Code 的 " 调试 " 页中,可以从目录调用启动配置 .vscode 来运行项目。In the Debug page of Visual Studio Code, you can invoke the launch configuration from the .vscode directory to run your project.

您必须创建 AKS 群集,并在 Visual Studio Code 外启用群集中的 Azure Dev Spaces。You must create your AKS cluster and enable Azure Dev Spaces in your cluster outside of Visual Studio Code. 您可以重复使用现有的 Dockerfile、Helm 图表和 azds.yaml 在 Visual Studio Code 之外创建的文件,例如通过运行生成的资产 azds prepYou can reuse existing Dockerfiles, Helm charts, and azds.yaml files created outside of Visual Studio Code, such as the assets generated by running azds prep. 如果确实要重复使用在 Visual Studio Code 之外生成的资产,则仍需拥有一个 .vscode 目录。If you do reuse assets generated outside of Visual Studio Code, you still need to have a .vscode directory. .vscode 目录可由 Visual Studio code 和 Azure Dev Spaces 扩展重新生成,并且不会覆盖现有资产。This .vscode directory can be regenerated by Visual Studio code and the Azure Dev Spaces extension and will not overwrite your existing assets.

对于 .NET Core 项目,必须安装 c # 扩展 ,才能从 Visual Studio Code 运行 .net 服务。For .NET Core projects, you must have the C# extension installed to run your .NET service from Visual Studio Code. 此外,对于使用 Maven 的 Java 项目,必须安装 java Azure Dev Spaces 调试器并安装 Maven 并 将其配置为从 Visual Studio Code 运行 java 服务。Also for Java projects using Maven, you must have the Java Debugger for Azure Dev Spaces extension installed as well as Maven installed and configured to run your Java service from Visual Studio Code.

在 AKS 中调试你的服务Debug your service in AKS

启动项目后,可以直接从 Visual Studio Code 调试开发环境中运行的 Java、Node.js 和 .NET Core 服务。After you launch your project, you can debug your Java, Node.js, and .NET Core services running in a dev space directly from Visual Studio Code. 目录中的 "启动配置" .vscode 提供其他调试信息,用于在开发人员空间中运行启用了调试的服务。The launch configuration in the .vscode directory provides the additional debugging information for running a service with debugging enabled in a dev space. Visual Studio Code 还会附加到开发空间中正在运行的容器中的调试进程,使你可以设置断点、检查变量和执行其他调试操作。Visual Studio Code also attaches to the debug process in the running container in your dev spaces, allowing you to set break points, inspect variables, and perform other debugging operations.

后续步骤Next steps

深入了解 Azure Dev Spaces 的工作方式。Learn more about how Azure Dev Spaces works.