<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>使用 Dapr .NET SDK 开发应用程序 on Dapr 文档库</title><link>https://v1-18.docs.dapr.io/zh-hans/developing-applications/sdks/dotnet/dotnet-development/</link><description>Recent content in 使用 Dapr .NET SDK 开发应用程序 on Dapr 文档库</description><generator>Hugo</generator><language>zh-hans</language><atom:link href="https://v1-18.docs.dapr.io/zh-hans/developing-applications/sdks/dotnet/dotnet-development/index.xml" rel="self" type="application/rss+xml"/><item><title>使用 Dapr CLI 进行 Dapr .NET SDK 开发</title><link>https://v1-18.docs.dapr.io/zh-hans/developing-applications/sdks/dotnet/dotnet-development/dotnet-development-dapr-cli/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/developing-applications/sdks/dotnet/dotnet-development/dotnet-development-dapr-cli/</guid><description>&lt;h2 id="dapr-cli">Dapr CLI&lt;/h2>
&lt;p>&lt;em>可以将其视为 &lt;a href="https://v1-18.docs.dapr.io/zh-hans/operations/hosting/self-hosted/self-hosted-with-docker/">.NET 伴侣指南：使用 Docker 的 Dapr 自托管指南&lt;/a>的补充&lt;/em>。&lt;/p>
&lt;p>Dapr CLI 通过初始化本地的 Redis 容器、Zipkin 容器、placement 服务和 Redis 的组件清单，为您提供了一个良好的基础环境。这使您能够在全新安装且无需额外设置的情况下使用以下功能模块：&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://v1-18.docs.dapr.io/zh-hans/developing-applications/building-blocks/service-invocation/">服务调用&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://v1-18.docs.dapr.io/zh-hans/developing-applications/building-blocks/state-management/">状态存储&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://v1-18.docs.dapr.io/zh-hans/developing-applications/building-blocks/pubsub/">发布/订阅&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://v1-18.docs.dapr.io/zh-hans/developing-applications/building-blocks/actors/">actor&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>您可以使用 &lt;code>dapr run&lt;/code> 命令来运行 .NET 服务，作为本地开发的一种策略。为每个服务运行此命令以启动您的应用程序。&lt;/p>
&lt;ul>
&lt;li>&lt;strong>优势：&lt;/strong> 由于这是 Dapr 默认安装的一部分，因此设置简单&lt;/li>
&lt;li>&lt;strong>劣势：&lt;/strong> 这会在您的机器上运行长时间的 Docker 容器，可能不太理想&lt;/li>
&lt;li>&lt;strong>劣势：&lt;/strong> 这种方法的可扩展性较差，因为需要为每个服务运行一个单独的命令&lt;/li>
&lt;/ul>
&lt;h3 id="使用-dapr-cli">使用 Dapr CLI&lt;/h3>
&lt;p>对于每个服务，您需要选择：&lt;/p>
&lt;ul>
&lt;li>用于寻址的唯一应用 ID (&lt;code>app-id&lt;/code>)&lt;/li>
&lt;li>用于 HTTP 的唯一监听端口 (&lt;code>port&lt;/code>)&lt;/li>
&lt;/ul>
&lt;p>您还应该决定存储组件的位置 (&lt;code>components-path&lt;/code>)。&lt;/p>
&lt;p>可以从多个终端运行以下命令以启动每个服务，并替换相应的值。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>dapr run --app-id &amp;lt;app-id&amp;gt; --app-port &amp;lt;port&amp;gt; --components-path &amp;lt;components-path&amp;gt; -- dotnet run -p &amp;lt;project&amp;gt; --urls http://localhost:&amp;lt;port&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>解释：&lt;/strong> 此命令使用 &lt;code>dapr run&lt;/code> 启动每个服务及其附属进程。命令的前半部分（在 &lt;code>--&lt;/code> 之前）将所需的配置传递给 Dapr CLI。命令的后半部分（在 &lt;code>--&lt;/code> 之后）将所需的配置传递给 &lt;code>dotnet run&lt;/code> 命令。&lt;/p></description></item><item><title>使用 .NET Aspire 进行 Dapr .NET SDK 开发</title><link>https://v1-18.docs.dapr.io/zh-hans/developing-applications/sdks/dotnet/dotnet-development/dotnet-development-dapr-aspire/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/developing-applications/sdks/dotnet/dotnet-development/dotnet-development-dapr-aspire/</guid><description>&lt;h1 id="net-aspire">.NET Aspire&lt;/h1>
&lt;p>&lt;a href="https://learn.microsoft.com/en-us/dotnet/aspire/get-started/aspire-overview">.NET Aspire&lt;/a> 是一款开发工具，旨在通过提供一个框架，简化外部软件与 .NET 应用程序的集成过程。该框架允许第三方服务轻松地与您的软件集成、监控和配置。&lt;/p>
&lt;p>Aspire 通过与流行的 IDE（包括 &lt;a href="https://visualstudio.microsoft.com/vs/">Microsoft Visual Studio&lt;/a>、&lt;a href="https://code.visualstudio.com/">Visual Studio Code&lt;/a>、&lt;a href="https://blog.jetbrains.com/dotnet/2024/02/19/jetbrains-rider-and-the-net-aspire-plugin/">JetBrains Rider&lt;/a> 等）深度集成，简化了本地开发。在启动调试器的同时，自动启动并配置对其他集成（包括 Dapr）的访问。&lt;/p>
&lt;p>虽然 Aspire 也支持将应用程序部署到各种云平台（如 Microsoft Azure 和 Amazon AWS），但本指南不涉及部署相关内容。更多信息请参阅 Aspire 的文档 &lt;a href="https://learn.microsoft.com/en-us/dotnet/aspire/deployment/overview">这里&lt;/a>。&lt;/p>
&lt;h2 id="先决条件">先决条件&lt;/h2>
&lt;ul>
&lt;li>Dapr .NET SDK 兼容 &lt;a href="https://dotnet.microsoft.com/download/dotnet/6.0">.NET 6&lt;/a>、&lt;a href="https://dotnet.microsoft.com/download/dotnet/8.0">.NET 8&lt;/a> 和 &lt;a href="https://dotnet.microsoft.com/download/dotnet/9.0">.NET 9&lt;/a>，但 .NET Aspire 仅支持 &lt;a href="https://dotnet.microsoft.com/download/dotnet/8.0">.NET 8&lt;/a> 和 &lt;a href="https://dotnet.microsoft.com/download/dotnet/9.0">.NET 9&lt;/a>。&lt;/li>
&lt;li>一个符合 OCI 标准的容器运行时，例如 &lt;a href="https://www.docker.com/products/docker-desktop">Docker Desktop&lt;/a> 或 &lt;a href="https://podman.io/">Podman&lt;/a>&lt;/li>
&lt;li>安装并初始化 Dapr v1.13 或更高版本&lt;/li>
&lt;/ul>
&lt;h2 id="通过-cli-使用-net-aspire">通过 CLI 使用 .NET Aspire&lt;/h2>
&lt;p>我们将从创建一个全新的 .NET 应用程序开始。打开您喜欢的 CLI 并导航到您希望创建新 .NET 解决方案的目录。首先使用以下命令安装一个模板，该模板将创建一个空的 Aspire 应用程序：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-sh" data-lang="sh">&lt;span style="display:flex;">&lt;span>dotnet new install Aspire.ProjectTemplates
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>安装完成后，继续在当前目录中创建一个空的 .NET Aspire 应用程序。&lt;code>-n&lt;/code> 参数允许您指定输出解决方案的名称。如果省略，.NET CLI 将使用输出目录的名称，例如 &lt;code>C:\source\aspiredemo&lt;/code> 将导致解决方案被命名为 &lt;code>aspiredemo&lt;/code>。本教程的其余部分将假设解决方案名为 &lt;code>aspiredemo&lt;/code>。&lt;/p></description></item><item><title>使用 Project Tye 进行 Dapr .NET SDK 开发</title><link>https://v1-18.docs.dapr.io/zh-hans/developing-applications/sdks/dotnet/dotnet-development/dotnet-development-tye/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/developing-applications/sdks/dotnet/dotnet-development/dotnet-development-tye/</guid><description>&lt;h2 id="project-tye">Project Tye&lt;/h2>
&lt;p>&lt;a href="https://github.com/dotnet/tye/">.NET Project Tye&lt;/a> 是一个专为简化运行多个 .NET 服务而设计的微服务开发工具。Tye 允许您将多个 .NET 服务、进程和容器镜像的配置整合为一个可运行的应用程序。&lt;/p>
&lt;p>对于 .NET Dapr 开发者来说，Tye 的优势在于：&lt;/p>
&lt;ul>
&lt;li>Tye 可以自动化使用 dapr CLI&lt;/li>
&lt;li>Tye 遵循 .NET 的约定，对 .NET 服务几乎无需额外配置&lt;/li>
&lt;li>Tye 能够管理容器中依赖项的生命周期&lt;/li>
&lt;/ul>
&lt;p>优缺点：&lt;/p>
&lt;ul>
&lt;li>&lt;strong>优点：&lt;/strong> Tye 可以自动化上述所有步骤。您无需再担心端口或应用程序 ID 等细节。&lt;/li>
&lt;li>&lt;strong>优点：&lt;/strong> 由于 Tye 也可以管理容器，您可以将这些容器作为应用程序的一部分定义，并避免机器上长时间运行的容器。&lt;/li>
&lt;/ul>
&lt;h3 id="使用-tye">使用 Tye&lt;/h3>
&lt;p>按照 &lt;a href="https://github.com/dotnet/tye/blob/master/docs/getting_started.md">Tye 入门指南&lt;/a> 安装 &lt;code>tye&lt;/code> CLI，并为您的应用程序创建 &lt;code>tye.yaml&lt;/code> 文件。&lt;/p>
&lt;p>接下来，按照 &lt;a href="https://github.com/dotnet/tye/blob/master/docs/recipes/dapr.md">Tye Dapr 配方&lt;/a> 中的步骤添加 Dapr。确保在 &lt;code>tye.yaml&lt;/code> 中使用 &lt;code>components-path&lt;/code> 指定组件文件夹的相对路径。&lt;/p>
&lt;p>然后，添加任何额外的容器依赖项，并将组件定义添加到您之前创建的文件夹中。&lt;/p>
&lt;p>您应该得到如下内容：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">store-application&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">extensions&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic"># Dapr 的配置在这里。&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>- &lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">dapr&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">components-path&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">&amp;lt;components-path&amp;gt; &lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#8f5902;font-style:italic"># 要运行的服务在这里。&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">services&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> 
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic"># 名称将用作应用程序 ID。对于 .NET 项目，Tye 只需要项目文件的路径。&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>- &lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">orders&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">project&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">orders/orders.csproj&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>- &lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">products&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">project&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">products/products.csproj&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>- &lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">store&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">project&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">store/store.csproj&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic"># 您想要运行的容器需要一个镜像名称和一组要暴露的端口。&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>- &lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">redis&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">image&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">redis&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">bindings&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>- &lt;span style="color:#204a87;font-weight:bold">port&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#0000cf;font-weight:bold">6973&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>将 &lt;code>tye.yaml&lt;/code> 和应用程序代码一起提交到源代码管理中。&lt;/p></description></item><item><title>使用 Docker-Compose 进行 Dapr .NET SDK 开发</title><link>https://v1-18.docs.dapr.io/zh-hans/developing-applications/sdks/dotnet/dotnet-development/dotnet-development-docker-compose/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/developing-applications/sdks/dotnet/dotnet-development/dotnet-development-docker-compose/</guid><description>&lt;h2 id="docker-compose">Docker-Compose&lt;/h2>
&lt;p>&lt;em>这可以看作是 &lt;a href="https://v1-18.docs.dapr.io/zh-hans/operations/hosting/self-hosted/self-hosted-with-docker/">.NET 伴侣指南：使用 Docker 的 Dapr 自托管指南&lt;/a> 的补充。&lt;/em>&lt;/p>
&lt;p>&lt;code>docker-compose&lt;/code> 是 Docker Desktop 附带的一个命令行工具，您可以用它同时运行多个容器。它提供了一种自动化管理多个容器生命周期的方法，为面向 Kubernetes 的应用程序提供类似于生产环境的开发体验。&lt;/p>
&lt;ul>
&lt;li>&lt;strong>优势在于：&lt;/strong> &lt;code>docker-compose&lt;/code> 帮助您管理容器，您可以将依赖项作为应用程序的一部分进行定义，并停止机器上长时间运行的容器。&lt;/li>
&lt;li>&lt;strong>劣势在于：&lt;/strong> 需要较多的前期投入，服务需要先容器化。&lt;/li>
&lt;li>&lt;strong>劣势在于：&lt;/strong> 如果您不熟悉 Docker，可能会遇到调试和故障排除的困难。&lt;/li>
&lt;/ul>
&lt;h3 id="使用-docker-compose">使用 docker-compose&lt;/h3>
&lt;p>从 .NET 的角度来看，使用 Dapr 的 &lt;code>docker-compose&lt;/code> 并不需要特别的指导。&lt;code>docker-compose&lt;/code> 负责运行容器，一旦您的服务在容器中，配置它就和其他编程技术类似。&lt;/p>


&lt;div class="alert alert-primary" role="alert">
&lt;h4 class="alert-heading">💡 应用端口&lt;/h4>

 在容器中，ASP.NET Core 应用程序默认监听 80 端口。请记住这一点，以便在配置 &lt;code>--app-port&lt;/code> 时使用。

&lt;/div>

&lt;p>总结这种方法：&lt;/p>
&lt;ul>
&lt;li>为每个服务创建一个 &lt;code>Dockerfile&lt;/code>&lt;/li>
&lt;li>创建一个 &lt;code>docker-compose.yaml&lt;/code> 并将其提交到源代码库&lt;/li>
&lt;/ul>
&lt;p>要了解如何编写 &lt;code>docker-compose.yaml&lt;/code>，您可以从 &lt;a href="https://github.com/dapr/samples/tree/master/hello-docker-compose">Hello, docker-compose 示例&lt;/a> 开始。&lt;/p>
&lt;p>类似于使用 &lt;code>dapr run&lt;/code> 本地运行，对于每个服务，您需要选择一个唯一的 app-id。选择容器名称作为 app-id 可以帮助您更容易记住。&lt;/p>
&lt;p>compose 文件至少应包含以下内容：&lt;/p>
&lt;ul>
&lt;li>容器之间通信所需的网络&lt;/li>
&lt;li>每个服务的容器&lt;/li>
&lt;li>一个 &lt;code>&amp;lt;service&amp;gt;-daprd&lt;/code> sidecar 容器，指定服务的端口和 app-id&lt;/li>
&lt;li>在容器中运行的其他依赖项（例如 redis）&lt;/li>
&lt;li>可选：Dapr placement 容器（用于 actor）&lt;/li>
&lt;/ul>
&lt;p>您还可以查看 &lt;a href="https://github.com/dotnet-architecture/eShopOnDapr/blob/master/docker-compose.yml">eShopOnContainers&lt;/a> 示例应用程序中的更大示例。&lt;/p></description></item></channel></rss>