其他
使用 .NET 7、Blazor 和 .NET MAUI 构建你自己的 Podcast App
点击上方蓝字
关注我们
.NET Podcast App https://github.com/microsoft/dotnet-podcasts
架构
Azure Container Apps
https://learn.microsoft.com/azure/container-apps/overview?ocid=AID3052907
API 更新
// Authentication and authorization-related services
builder.Services.AddMicrosoftIdentityWebApiAuthentication(builder.Configuration);
builder.Services.AddAuthorizationBuilder().AddPolicy("modify_feeds", policy => policy.RequireScope("API.Access"));
// OpenAPI and versioning-related services
builder.Services.AddSwaggerGen();
builder.Services.Configure<SwaggerGeneratorOptions>(opts =>
{
opts.InferSecuritySchemes = true;
});
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddApiVersioning(options =>
{
options.DefaultApiVersion = new ApiVersion(2, 0);
options.ReportApiVersions = true;
options.AssumeDefaultVersionWhenUnspecified = true;
options.ApiVersionReader = new HeaderApiVersionReader("api-version");
});
// Enable Output Cache
builder.Services.AddOutputCache();
// Rate-limiting and output caching-related services
builder.Services.AddRateLimiter(options => options.AddFixedWindowLimiter("feeds", options =>
{
options.PermitLimit = 5;
options.QueueProcessingOrder = QueueProcessingOrder.OldestFirst;
options.QueueLimit = 0;
options.Window = TimeSpan.FromSeconds(2);
options.AutoReplenishment = false;
}));
// Create version set
var versionSet = app.NewApiVersionSet()
.HasApiVersion(1.0)
.HasApiVersion(2.0)
.ReportApiVersions()
.Build();
// create new mapping for apis
var shows = app.MapGroup("/shows");
shows
.MapShowsApi()
.WithApiVersionSet(versionSet)
.MapToApiVersion(1.0)
.MapToApiVersion(2.0);
可观察性和监控
builder.Services.AddOpenTelemetryTracing(tracing =>
tracing.SetResourceBuilder(serviceResource)
.AddAzureMonitorTraceExporter(o =>
{
o.ConnectionString = azureMonitorConnectionString;
})
.AddJaegerExporter()
.AddHttpClientInstrumentation()
.AddAspNetCoreInstrumentation()
.AddEntityFrameworkCoreInstrumentation()
);
builder.Services.AddOpenTelemetryMetrics(metrics =>
{
metrics
.SetResourceBuilder(serviceResource)
.AddPrometheusExporter()
.AddAzureMonitorMetricExporter(o =>
{
o.ConnectionString = azureMonitorConnectionString;
})
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation()
.AddProcessInstrumentation()
.AddHttpClientInstrumentation()
.AddEventCountersInstrumentation(ec =>
{
ec.AddEventSources("Microsoft.AspNetCore.Hosting");
});
});
builder.Logging.AddOpenTelemetry(logging =>
{
logging
.SetResourceBuilder(serviceResource)
.AddAzureMonitorLogExporter(o =>
{
o.ConnectionString = azureMonitorConnectionString;
})
.AttachLogsToActivityEvent();
});
.NET SDK 容器
<PropertyGroup>
<ContainerImageName>podcastapi</ContainerImageName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Build.Containers" Version="0.2.7" />
</ItemGroup>
dotnet publish -c Release -r linux-x64 -p PublishProfile=DefaultContainer src/Services/Podcasts/Podcast.API/Podcast.API.csproj
Playwright 测试
Power Apps 集成
Azure API Management
https://learn.microsoft.com/azure/api-management/?ocid=AID3052907
GitHub 存储库有新手指导,介绍了如何轻松地让整个应用程序在本地运行,只需一个简单的命令就能进行开发。此外,你可以通过在克隆的 repo 中设置一些 GitHub secrets 来用 GitHub Actions 实现完整的持续集成和部署管道,将整个解决方案部署到 Azure 平台上。除了运行应用程序,你还可以在新手指导中找到 .NET Conf 的所有 demo。
新手指导
https://github.com/microsoft/dotnet-podcasts#local-deployment-quickstart
GitHub 讨论组
https://github.com/microsoft/dotnet-podcasts/discussions
*未经授权请勿私自转载此文章及图片。