You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

独立模式.NET Aspire Dashboard资源UI启用报错求助

在Docker独立模式.NET Aspire Dashboard中启用资源UI遇到Grpc未实现错误

我尝试在Docker部署的独立模式.NET Aspire Dashboard中启用资源UI,按照文档通过docker-compose设置了环境变量配置相关选项:

services:
  aspire-dashboard:
    container_name: "aspire-dashboard"
    image: "mcr.microsoft.com/dotnet/aspire-dashboard:8.0"
    environment:
      DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS: "true"
      DASHBOARD__RESOURCESERVICECLIENT__AUTHMODE: "ApiKey"
      DASHBOARD__RESOURCESERVICECLIENT__APIKEY: "1234567"
      DASHBOARD__RESOURCESERVICECLIENT__URL: "http://localhost:20213"
    ports:
    - target: 18888
      published: 18888
    restart: unless-stopped
  cache:
    container_name: "cache"
    image: "docker.io/library/redis:7.4"
    environment:
      OTEL_EXPORTER_OTLP_ENDPOINT: "http://aspire-dashboard:18889"
      OTEL_SERVICE_NAME: "cache"
    ports:
    - target: 6379
      published: 6379
    restart: unless-stopped
  apiservice:
    container_name: "apiservice"
    image: "apiservice:latest"
    environment:
      OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: "true"
      OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: "true"
      OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: "in_memory"
      ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true"
      HTTP_PORTS: "8080"
      OTEL_EXPORTER_OTLP_ENDPOINT: "http://aspire-dashboard:18889"
      OTEL_SERVICE_NAME: "apiservice"
    ports:
    - target: 8080
      published: 10000
    - target: 8443
      published: 10001
    restart: unless-stopped
  aspirestudyexternalapi:
    container_name: "aspirestudyexternalapi"
    image: "aspire-study-external-api:latest"
    environment:
      OTEL_EXPORTER_OTLP_ENDPOINT: "http://aspire-dashboard:18889"
      OTEL_SERVICE_NAME: "aspirestudyexternalapi"
    ports:
    - target: 8080
      published: 5000
    restart: unless-stopped
  webfrontend:
    container_name: "webfrontend"
    image: "webfrontend:latest"
    environment:
      OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: "true"
      OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: "true"
      OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: "in_memory"
      ASPNETCORE_FORWARDEDHEADERS_ENABLED: "true"
      HTTP_PORTS: "8080"
      ConnectionStrings__cache: "cache:6379"
      services__apiservice__http__0: "http://apiservice:8080"
      services__aspirestudyexternalapi__http__0: "http://aspirestudyexternalapi:8080"
      OTEL_EXPORTER_OTLP_ENDPOINT: "http://aspire-dashboard:18889"
      OTEL_SERVICE_NAME: "webfrontend"
    ports:
    - target: 8080
      published: 10002
    - target: 8443
      published: 10003
    restart: unless-stopped

仪表盘页面已经显示资源和控制台标签,但容器日志抛出错误:

aspire-dashboard  | fail: Aspire.Dashboard.Model.DashboardClient[0]
aspire-dashboard  |       Error #1 watching resources.
aspire-dashboard  |       Grpc.Core.RpcException: Status(StatusCode="Unimplemented", Detail="Service is unimplemented.")
aspire-dashboard  |          at Grpc.Net.Client.Internal.Retry.RetryCallBaseClientStreamReader`2.MoveNext(CancellationToken cancellationToken)
aspire-dashboard  |          at Grpc.Core.AsyncStreamReaderExtensions.ReadAllAsyncCore[T](IAsyncStreamReader`1 streamReader, CancellationToken cancellationToken)+MoveNext()
aspire-dashboard  |          at Grpc.Core.AsyncStreamReaderExtensions.ReadAllAsyncCore[T](IAsyncStreamReader`1 streamReader, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
aspire-dashboard  |          at Aspire.Dashboard.Model.DashboardClient.<>c__DisplayClass27_1.<<EnsureInitialized>g__WatchResourcesAsync|5>d.MoveNext() in /_/src/Aspire.Dashboard/Model/DashboardClient.cs:line 293
aspire-dashboard  |       --- End of stack trace from previous location ---
aspire-dashboard  |          at Aspire.Dashboard.Model.DashboardClient.<>c__DisplayClass27_1.<<EnsureInitialized>g__WatchResourcesAsync|5>d.MoveNext() in /_/src/Aspire.Dashboard/Model/DashboardClient.cs:line 293
aspire-dashboard  |       --- End of stack trace from previous location ---
aspire-dashboard  |          at Aspire.Dashboard.Model.DashboardClient.<>c__DisplayClass27_0.<<EnsureInitialized>g__WatchResourcesWithRecoveryAsync|3>d.MoveNext() in /_/src/Aspire.Dashboard/Model/DashboardClient.cs:line 274

不确定是否能实现预期效果,有没有人尝试过类似操作?


问题分析与解决思路

这个Unimplemented的Grpc错误,核心原因是你配置的DASHBOARD__RESOURCESERVICECLIENT__URL指向的http://localhost:20213并没有提供Aspire资源服务的Grpc端点。独立模式的Aspire Dashboard本身默认不包含资源服务,资源服务是Aspire AppHost的一部分。

具体修正步骤

  • 修正资源服务地址:Docker容器内的localhost指向容器自身,如果你要连接宿主机上的Aspire AppHost,Docker Desktop环境下可以用host.docker.internal替代localhost;如果AppHost也在Docker容器中,要把它加入同一个Docker网络,用容器名或服务名作为地址。
  • 确保AppHost启用资源服务:Aspire AppHost项目必须显式配置资源服务,并且和Dashboard的AuthMode、ApiKey保持一致,示例代码如下:
    var builder = DistributedApplication.CreateBuilder(args);
    // 启用资源服务并配置鉴权
    builder.AddResourceService(options =>
    {
        options.AuthMode = ResourceServiceAuthMode.ApiKey;
        options.ApiKey = "1234567";
    });
    builder.Build().Run();
    
  • 验证端口与网络可达性:确认AppHost的资源服务端口(默认20213)已正确暴露,并且Dashboard容器能正常访问该端口。

额外说明

独立模式的Aspire Dashboard默认仅能接收OTEL遥测数据(即当前显示的服务监控信息),完整的资源UI功能必须依赖Aspire AppHost提供的资源服务才能正常工作,没有AppHost的情况下,资源标签页会因为无法获取数据而报错。

内容的提问来源于stack exchange,提问作者Aleksander Michalec

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 22:14:53