Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Community Article: .NET Aspire #18146

Closed
EngincanV opened this issue Nov 15, 2023 · 11 comments · Fixed by #20133
Closed

Community Article: .NET Aspire #18146

EngincanV opened this issue Nov 15, 2023 · 11 comments · Fixed by #20133

Comments

@EngincanV
Copy link
Member

EngincanV commented Nov 15, 2023

The first preview of .NET Aspire is available with the .NET 8 release and it seems very promising.

Here is its repository: https://github.com/dotnet/aspire
/ docs: https://learn.microsoft.com/en-us/dotnet/aspire/
/ and samples: https://github.com/dotnet/aspire-samples

Check the .NET Aspire, deep dive it, and create a community article for it.

@EngincanV EngincanV added this to the 8.1-preview milestone Nov 15, 2023
@EngincanV EngincanV self-assigned this Nov 15, 2023
@helloxubo
Copy link

Aspire looks very nice and hopefully integrated with ABP.

@leonkosak
Copy link
Contributor

@helloxubo, I wouldn't integrate it in abp, because it's opinionated stack. Community article or even better - deployment documentation option inside docs.abp.io is a better approach.

@EngincanV
Copy link
Member Author

@helloxubo, I wouldn't integrate it in abp, because it's opinionated stack. Community article or even better - deployment documentation option inside docs.abp.io is a better approach.

I agree with you.

@umerkle
Copy link

umerkle commented Dec 23, 2023

@maliming mentioned, that abp will switch to Aspire in the near future here

I think Aspire will be the future, not tye anymore.

@leonkosak
Copy link
Contributor

@berkansasmaz (or @EngincanV), what would this community article cover?
Is it viable to expect how to run a layered MVC (and/or Blazor) solution?

I am also looking at ABP Studio and want to figure what Studio offers more compared to Aspire regarding running abp-based solution in kubernetes.

Thank you for explanations.

@berkansasmaz
Copy link
Member

berkansasmaz commented Mar 8, 2024

@berkansasmaz (or @EngincanV), what would this community article cover? Is it viable to expect how to run a layered MVC (and/or Blazor) solution?

I am also looking at ABP Studio and want to figure what Studio offers more compared to Aspire regarding running abp-based solution in kubernetes.

Thank you for explanations.

Yes, I want to explain how to run a layered MVC (and/or Blazor) solution, but at this stage, we should not expect 100% compatibility with some of Aspire's Components.

I haven't fully investigated Aspire's Aspir8 (aspire for K8s) project, so I can't say anything comparatively. However, if you want to learn about the features ABP Studio provides for Kubernetes, you can look here.

@berkansasmaz berkansasmaz modified the milestones: 8.2-preview, 8.3-preview Apr 24, 2024
@kfrancis
Copy link

kfrancis commented May 7, 2024

Well, if I can figure out how to migrate the db in the correct way ..

image

@leonkosak
Copy link
Contributor

@kfrancis, as I understand, only running dbmigrator project is the only thing that is not resolved (and all other projects are running in Aspire)?

@kfrancis
Copy link

kfrancis commented May 7, 2024

@kfrancis, as I understand, only running dbmigrator project is the only thing that is not resolved (and all other projects are running in Aspire)?

It seems to be running the sites as expected, the only tricky bit seems to be the SQL. They all seem to be communicating with the same SQL instance now that I modified the factory:

var builder = new DbContextOptionsBuilder<BookStoreDbContext>()
    .UseSqlServer("sqldata");

and here's my host config:

var builder = DistributedApplication.CreateBuilder(args);

var cache = builder.AddRedis("RedisConnection");

var sql = builder.AddSqlServer("sql");
var sqldb = sql.AddDatabase("sqldb");

builder.AddProject<Projects.Acme_BookStore_AuthServer>("acme-bookstore-authserver")
    .WithHttpsEndpoint(port: 44387)
    .WithReference(cache)
    .WithReference(sqldb);

builder.AddProject<Projects.Acme_BookStore_HttpApi_Host>("acme-bookstore-httpapi-host")
    .WithHttpsEndpoint(port: 44358)
    .WithReference(cache)
    .WithReference(sqldb);

builder.AddProject<Projects.Acme_BookStore_Web>("acme-bookstore-web")
    .WithHttpsEndpoint(port: 44336)
    .WithReference(cache)
    .WithReference(sqldb);

//builder.AddProject<Projects.Acme_BookStore_DbMigrator>("acme-bookstore-dbmigrator")
//    .WithReference(sqldb);

builder.Build().Run();

So, while I can have it run the migrator - when I do it seems to be trying to migrate more than once?
image

@kfrancis
Copy link

kfrancis commented May 7, 2024

Structured logs work:
image

Just adding Serilog.Sinks.OpenTelemetry to web, httpapi.host and authserver and changing:

builder.Host
    .AddAppSettingsSecretsJson()
    .UseAutofac()
    .UseSerilog();

// To this
builder.Host
    .AddAppSettingsSecretsJson()
    .UseAutofac()
    .UseSerilog((ctx, lc) => lc
        .Enrich.FromLogContext()
        .WriteTo.OpenTelemetry(options =>
        {
            options.Endpoint = builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"];
            var headers = builder.Configuration["OTEL_EXPORTER_OTLP_HEADERS"]?.Split(',') ?? [];
            foreach (var header in headers)
            {
                var (key, value) = header.Split('=') switch
                {
                [string k, string v] => (k, v),
                    var v => throw new Exception($"Invalid header format {v}")
                };

                options.Headers.Add(key, value);
            }
            options.ResourceAttributes.Add("service.name", ctx.HostingEnvironment.ApplicationName.ToLower().Replace(".","-"));

            //To remove the duplicate issue, we can use the below code to get the key and value from the configuration

            var (otelResourceAttribute, otelResourceAttributeValue) = builder.Configuration["OTEL_RESOURCE_ATTRIBUTES"]?.Split('=') switch
            {
            [string k, string v] => (k, v),
                _ => throw new Exception($"Invalid header format {builder.Configuration["OTEL_RESOURCE_ATTRIBUTES"]}")
            };

            options.ResourceAttributes.Add(otelResourceAttribute, otelResourceAttributeValue);
        })
        .ReadFrom.Configuration(ctx.Configuration));

Just reading through serilog/serilog-aspnetcore#359

@EngincanV
Copy link
Member Author

https://community.abp.io/posts/how-to-use-.net-aspire-with-abp-framework-h29km4kk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants