惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
InfoQ
C
CERT Recently Published Vulnerability Notes
The Last Watchdog
The Last Watchdog
P
Proofpoint News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
P
Privacy & Cybersecurity Law Blog
Simon Willison's Weblog
Simon Willison's Weblog
Jina AI
Jina AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
博客园_首页
F
Fortinet All Blogs
博客园 - Franky
Latest news
Latest news
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
D
Docker
Project Zero
Project Zero
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
Cisco Talos Blog
Cisco Talos Blog
Y
Y Combinator Blog
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
H
Help Net Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
PCI Perspectives
PCI Perspectives
Cloudbric
Cloudbric
V
Visual Studio Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理

博客园 - 黄明基

解剖一个桌面级 AI Copilot 的架构:Stargazer AI Copilot(.NET 10 + Avalonia)是怎么“分层”的 StargazerLab Copilot使用说明 🚀 用 .NET + Avalonia 打造你的专属 AI Copilot 桌面端 分布式应用框架Microsoft Orleans - 7、基于 Microsoft Orleans 构建模块化微服务:用户、消息与存储三大核心模块解析 Semantic Kernel人工智能开发 - 第六章:Semantic Kernel的安全与过滤器机制——构建可信赖的AI应用防护体系 Semantic Kernel人工智能开发 - 第五章:提示词工程与模板优化——释放大语言模型真正潜力 Semantic Kernel人工智能开发 - 第四章:Semantic Kernel内存管理系统——为AI注入持久记忆与上下文感知能力 Semantic Kernel人工智能开发 - 第三章:Semantic Kernel插件系统详解——扩展AI能力的核心引擎 Semantic Kernel人工智能开发 - 第二章:环境搭建与第一个AI应用——从零开始构建智能对话系统 Semantic Kernel人工智能开发 - 第一章:Semantic Kernel框架概览——开启智能应用开发之门 结合.NET Aspire与Spring Boot:构建可观测的云原生Java应用 分布式应用框架Microsoft Orleans - 6、构建高可用Orleans应用:集群配置与容灾机制详解 分布式应用框架Microsoft Orleans - 5、掌握Orleans高级特性:计时器、提醒与流处理详解 分布式应用框架Microsoft Orleans - 4、掌握Microsoft Orleans状态管理:从持久化配置到事务处理 分布式应用框架Microsoft Orleans - 3、深入解析Orleans核心要素:Grain与Silo的工作原理 分布式应用框架Microsoft Orleans - 2、动手实践:构建你的第一个Microsoft Orleans应用程序 分布式应用框架Microsoft Orleans - 1、Microsoft Orleans简介 AI真的太好用啦!Aspire Dashboard集成GitHub Copilot。 智能助手客户端 设计模式学习:状态模式实现订单状态流转 设计模式学习:在支付系统中的实战应用 跨平台桌面应用开发:解锁 Electron 与 shadcn/ui 的潜力
构建你的.NET Aspire解决方案
黄明基 · 2024-12-05 · via 博客园 - 黄明基

.NET Aspire 是一组功能强大的工具、模板和包,用于构建可观察的生产就绪应用程序。.NET Aspire 通过处理特定云原生问题的 NuGet 包集合提供。云原生应用程序通常由小型互连部分或微服务组成,而不是单个整体式代码库。云原生应用程序通常会消耗大量的服务,例如数据库、消息收发和缓存。

.NET Aspire 旨在改善构建 .NET 云原生应用程序的体验。它提供了一组一致的、有主见的工具和模式,可帮助您构建和运行分布式应用程序。NET Aspire 旨在帮助您:

  • 编排:.NET Aspire 为本地开发环境提供了运行和连接多项目应用程序及其依赖项的功能。
  • 集成:.NET Aspire 集成是适用于常用服务(如 Redis 或 Postgres)的 NuGet 包,具有标准化接口,可确保它们与您的应用程序一致且无缝地连接。
  • 工具:.NET Aspire 附带适用于 Visual Studio、Visual Studio Code 和 .NET CLI 的项目模板和工具体验,可帮助你创建 .NET Aspire 项目并与之交互。

前提条件

安装.NET Aspire 模板

如果尚未安装 .NET Aspire 模板,请运行以下命令:

dotnet new install Aspire.ProjectTemplates

完成安装后,执行一下命令可看到aspire项目模板:

dotnet new list aspire

模板名                        短名称                  语言  标记
----------------------------  ----------------------  ----  -------------------------------------------------------
.NET Aspire 入门应用          aspire-starter          [C#]  Common/.NET Aspire/Blazor/Web/Web API/API/Service/Cloud
.NET Aspire 应用主机          aspire-apphost          [C#]  Common/.NET Aspire/Cloud
.NET Aspire 服务默认值        aspire-servicedefaults  [C#]  Common/.NET Aspire/Cloud/Web/Web API/API/Service
.NET Aspire 测试项目(MSTest)  aspire-mstest           [C#]  Common/.NET Aspire/Cloud/Web/Web API/API/Service/Test
.NET Aspire 测试项目(NUnit)   aspire-nunit            [C#]  Common/.NET Aspire/Cloud/Web/Web API/API/Service/Test
.NET Aspire 测试项目(xUnit)   aspire-xunit            [C#]  Common/.NET Aspire/Cloud/Web/Web API/API/Service/Test
.NET Aspire 空应用            aspire                  [C#]  Common/.NET Aspire/Cloud/Web/Web API/API/Service

从模板创建 .NET Aspire 空应用,请运行以下命令:

dotnet new aspire -o Stargazer

创建的应用是一个最小的 .NET Aspire 项目,包括以下内容:

集成服务

加入适用于常用服务(如 Redis 或 Postgres)的 NuGet 包Aspire.Hosting.PostgreSQLAspire.Hosting.RedisAspire.Hosting.MongoDB,然后在代码中创建docker容器:

using System.Runtime.InteropServices;

var builder = DistributedApplication.CreateBuilder(args);

string redisImage = "hub.atomgit.com/amd64/redis";
string postgresqlImage = "hub.atomgit.com/amd64/postgres";
string mongodbImage = "hub.atomgit.com/amd64/mongo";
Architecture architecture = RuntimeInformation.ProcessArchitecture;
if(architecture == Architecture.Arm
   || architecture == Architecture.Arm64)
{
    redisImage = "hub.atomgit.com/arm64v8/redis";
    postgresqlImage = "hub.atomgit.com/arm64v8/postgres";
    mongodbImage = "hub.atomgit.com/arm64v8/mongo";
}
    
var redis = builder.AddRedis("redis", 6379)
    .WithContainerName("redis")
    .WithImage(redisImage, "7-alpine")
    .WithDataVolume("redis")
    .WithRedisCommander(null, "redis-commander");

var username = builder.AddParameter("postgres-uid", "postgres");
var password = builder.AddParameter("postgres-pwd", "123456");
var postgres = builder.AddPostgres("postgres", username, password, 5432)
    .WithContainerName("postgres")
    .WithImage(postgresqlImage, "15-alpine")
    .WithDataVolume("postgres");
var postgresql = postgres.AddDatabase("postgresql");

var mongoUser = builder.AddParameter("mongo-user", "root");
var mongoPwd = builder.AddParameter("mongo-pwd", "123456");
var mongo = builder.AddMongoDB("mongo", 27017, mongoUser, mongoPwd)
    .WithContainerName("mongo")
    .WithImage(mongodbImage, "7-jammy")
    .WithDataVolume("mongo");
var mongodb = mongo.AddDatabase("mongodb");

IResourceBuilder<ProjectResource> apiService = builder.AddProject<Projects.Stargazer_Abp_Template_Host>("api-service");

builder.AddProject<Projects.Stargazer_Abp_Template_Web>("frontend")
    .WithExternalHttpEndpoints()
    .WithReference(redis)
    .WithReference(postgresql)
    .WithReference(mongodb)
    .WaitFor(redis)
    .WaitFor(postgres)
    .WaitFor(mongodb)
    .WithReference(apiService);

builder.Build().Run();

启动应用程序

运行以下命令启动应用程序:

dotnet run --project Stargazer.AppHost


访问https://localhost:17125/login?t=337c3ec0bfdadd302fcdb467d76453ad,就可以使用.NET Aspire 仪表板。

访问仪表板上的链接http://localhost:5136/,就可以访问应用程序。

首发网站:https://stargazer.tech/2024/12/05/build-your-dotnet-aspire-solution/
相关链接