{"id":43731,"date":"2022-12-19T10:05:00","date_gmt":"2022-12-19T18:05:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/dotnet\/?p=43731"},"modified":"2023-01-17T15:52:53","modified_gmt":"2023-01-17T23:52:53","slug":"build-your-own-podcast-app-with-dotnet-blazor-and-dotnet-maui","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/build-your-own-podcast-app-with-dotnet-blazor-and-dotnet-maui\/","title":{"rendered":"Build Your Own Podcast App with .NET 7, Blazor, and .NET MAUI"},"content":{"rendered":"<p>The <a href=\"https:\/\/github.com\/microsoft\/dotnet-podcasts\">.NET Podcast app<\/a> was first introduced at .NET Conf 2021 and recently updated to highlight new features in .NET 7 at the <a href=\"https:\/\/www.youtube.com\/watch?v=8V_BUGFKdaI\">.NET Conf 2022 keynote<\/a>. The podcast app is ready to use sample application that showcases .NET, ASP.NET Core, Blazor, .NET MAUI, Azure Container Apps, Orleans, Power Platform, Playwright, and more. In this post, I&#8217;ll explain all the new features and show how we upgraded the .NET Podcast app to take advantage of them.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2023\/01\/dotnet-podcasts.png\" alt=\".NET Podcast application running on phones, browser, and desktop\" \/><\/p>\n<h2>Architecture<\/h2>\n<p>As mentioned, the .NET Podcast app uses a cloud-native architecture to power the mobile, desktop, and web apps.  Microservices were used for the worker services that add and update the podcasts feeds and the APIs that serve up data to the apps. These are all powered by <a href=\"https:\/\/learn.microsoft.com\/azure\/container-apps\/overview\">Azure Container Apps<\/a> to dynamically scale the microservices based on the different characteristics of each service.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2023\/01\/dotnet-podcasts-architecture.png\" alt=\"Architecture diagram for the dotnet podcast app\" \/><\/p>\n<p>There is a lot more to the .NET Podcast app including integration into Azure SQL Server for our database, Azure Storage to save images and queuing submissions, and Azure API Management to leverage the APIs in Power Apps and Power Automate.<\/p>\n<h2>API Updates<\/h2>\n<p>The .NET Podcast APIs have been updated to use the latest features in ASP.NET Core including <a href=\"https:\/\/learn.microsoft.com\/aspnet\/core\/performance\/caching\/output\">Output Cache<\/a>, <a href=\"https:\/\/learn.microsoft.com\/aspnet\/core\/performance\/rate-limit\">Rate Limiting<\/a>, <a href=\"https:\/\/github.com\/dotnet\/aspnet-api-versioning#aspnet-api-versioning\">API Versioning<\/a>, and new <a href=\"https:\/\/learn.microsoft.com\/aspnet\/core\/fundamentals\/minimal-apis#route-groups\">Route Groups for Minimal APIs<\/a>. Additionally, it integrates the latest enhancements with authentication and authorization that great simplifies these features for developers.<\/p>\n<pre><code class=\"language-csharp\">\/\/ Authentication and authorization-related services\n\nbuilder.Services.AddMicrosoftIdentityWebApiAuthentication(builder.Configuration);\n\nbuilder.Services.AddAuthorizationBuilder().AddPolicy(\"modify_feeds\", policy =&gt; policy.RequireScope(\"API.Access\"));\n\n\/\/ OpenAPI and versioning-related services\nbuilder.Services.AddSwaggerGen();\nbuilder.Services.Configure&lt;SwaggerGeneratorOptions&gt;(opts =&gt;\n{\n    opts.InferSecuritySchemes = true;\n});\nbuilder.Services.AddEndpointsApiExplorer();\nbuilder.Services.AddApiVersioning(options =&gt;\n{\n    options.DefaultApiVersion = new ApiVersion(2, 0);\n    options.ReportApiVersions = true;\n    options.AssumeDefaultVersionWhenUnspecified = true;\n    options.ApiVersionReader = new HeaderApiVersionReader(\"api-version\");\n});\n\n\/\/ Enable Output Cache\nbuilder.Services.AddOutputCache();\n\n\/\/ Rate-limiting and output caching-related services\nbuilder.Services.AddRateLimiter(options =&gt; options.AddFixedWindowLimiter(\"feeds\", options =&gt;\n{\n    options.PermitLimit = 5;\n    options.QueueProcessingOrder = QueueProcessingOrder.OldestFirst;\n    options.QueueLimit = 0;\n    options.Window = TimeSpan.FromSeconds(2);\n    options.AutoReplenishment = false;\n}));\n\n\/\/ Create version set\nvar versionSet = app.NewApiVersionSet()\n                    .HasApiVersion(1.0)\n                    .HasApiVersion(2.0)\n                    .ReportApiVersions()\n                    .Build();\n\n\/\/ create new mapping for apis\nvar shows = app.MapGroup(\"\/shows\");\n\nshows\n    .MapShowsApi()\n    .WithApiVersionSet(versionSet)\n    .MapToApiVersion(1.0)\n    .MapToApiVersion(2.0);<\/code><\/pre>\n<p>Looking for more updates with APIs in .NET 7? Checkout the <a href=\"https:\/\/www.youtube.com\/watch?v=HXHwtEjQoyM\">Making the Most of Minimal APIs in .NET 7<\/a> from .NET Conf.<\/p>\n<h2>Observability &amp; Monitoring<\/h2>\n<p>Once you have built and deployed your services, you need to observe and monitor them. During the keynote we showed how to integrate Open Telemetry, Azure Monitor, and more in just a few lines of code to completely instrument your services.<\/p>\n<pre><code class=\"language-csharp\">builder.Services.AddOpenTelemetryTracing(tracing =&gt;\n        tracing.SetResourceBuilder(serviceResource)\n        .AddAzureMonitorTraceExporter(o =&gt;\n        {\n            o.ConnectionString = azureMonitorConnectionString;\n        })\n        .AddJaegerExporter()\n        .AddHttpClientInstrumentation()\n        .AddAspNetCoreInstrumentation()\n        .AddEntityFrameworkCoreInstrumentation()\n    );\n\nbuilder.Services.AddOpenTelemetryMetrics(metrics =&gt;\n{\n    metrics\n    .SetResourceBuilder(serviceResource)\n    .AddPrometheusExporter()\n    .AddAzureMonitorMetricExporter(o =&gt;\n    {\n        o.ConnectionString = azureMonitorConnectionString;\n    })\n    .AddAspNetCoreInstrumentation()\n    .AddHttpClientInstrumentation()\n    .AddRuntimeInstrumentation()\n    .AddProcessInstrumentation()\n    .AddHttpClientInstrumentation()\n    .AddEventCountersInstrumentation(ec =&gt;\n    {\n        ec.AddEventSources(\"Microsoft.AspNetCore.Hosting\");\n    });\n});\n\nbuilder.Logging.AddOpenTelemetry(logging =&gt;\n{\n    logging\n    .SetResourceBuilder(serviceResource)\n    .AddAzureMonitorLogExporter(o =&gt;\n    {\n        o.ConnectionString = azureMonitorConnectionString;\n    })\n    .AttachLogsToActivityEvent();\n});<\/code><\/pre>\n<h2>.NET SDK Containers<\/h2>\n<p>The .NET Podcast application is powered by microservices and containers. The <a href=\"https:\/\/devblogs.microsoft.com\/dotnet\/announcing-builtin-container-support-for-the-dotnet-sdk\/\">.NET SDK can now containerize your app<\/a> with just a few configuration changes. This feature is now integrated into the services that power the .NET Podcast app and the CI\/CD pipeline as well.<\/p>\n<pre><code class=\"language-xml\">&lt;PropertyGroup&gt;\n    &lt;ContainerImageName&gt;podcastapi&lt;\/ContainerImageName&gt;\n&lt;\/PropertyGroup&gt;\n\n&lt;ItemGroup&gt;\n    &lt;PackageReference Include=\"Microsoft.NET.Build.Containers\" Version=\"0.2.7\" \/&gt;\n&lt;\/ItemGroup&gt;<\/code><\/pre>\n<pre><code class=\"language-yml\">dotnet publish -c Release -r linux-x64 -p PublishProfile=DefaultContainer src\/Services\/Podcasts\/Podcast.API\/Podcast.API.csproj<\/code><\/pre>\n<p>If you are interested in containers and microservices be sure to watch some of these sessions from .NET Conf:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=FLGFzlWF4Gs\">Using .NET with Chiseled Ubuntu Containers<\/a><\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=Blhk-F_m0LU\">Azure Container Apps with .NET<\/a><\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=NBbI52liUR4\">State of Azure + .NET<\/a><\/li>\n<\/ul>\n<h2>Playwright Tests<\/h2>\n<p><a href=\"https:\/\/playwright.dev\/\">Playwright<\/a> is an open source testing framework from Microsoft that enables reliable end-to-end testing for modern web apps. As the team was working on backend and frontend updates, they wanted to ensure that the core scenarios of the podcast app didn&#8217;t break. They setup several Playwright tests and integrated it into their CI pipeline so they ran with every pull request. <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2023\/01\/playwright-tests.png\" alt=\"Playwright run results from GitHub Actions\" \/><\/p>\n<p>Checkout the <a href=\"https:\/\/www.youtube.com\/watch?v=gBky9_AskNQ\">session from .NET Conf<\/a> from Max and Debbie from the Playwright team on testing Blazor apps with Playwright:<\/p>\n<p><iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/gBky9_AskNQ\" allowfullscreen><\/iframe><\/p>\n<h2>Power App Integration<\/h2>\n<p>With <a href=\"https:\/\/learn.microsoft.com\/azure\/api-management\/\">Azure API Management<\/a>(APIM) you can easily take your .NET APIs to power more services and apps including the Power Platform. During .NET Conf 2022, we showcased a Power App that would triage approving and denying new podcast submissions with .NET APIs that were surfaced through APIM. Now included in the repo is the full Power App the you can deploy yourself.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2023\/01\/dotnet-podcasts-powerapp-scaled.jpg\" alt=\"Power Platform designer showing podcast app and API\" \/><\/p>\n<p>Be sure to watch the <a href=\"https:\/\/www.youtube.com\/watch?v=qd7x2pH4rwo\">APIM and Power Apps session from .NET Conf<\/a>: <\/p>\n<p><iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/qd7x2pH4rwo\" allowfullscreen><\/iframe><\/p>\n<h2>Give it a try today<\/h2>\n<p>The GitHub repository has <a href=\"https:\/\/github.com\/microsoft\/dotnet-podcasts#local-deployment-quickstart\">step-by-step directions<\/a> on how to easily get the entire application running locally for development with just one simple command. Additionally, you can set a <a href=\"https:\/\/github.com\/microsoft\/dotnet-podcasts\/blob\/main\/Deploy-websites-services.md\">full continuous integration and deployment pipeline<\/a> with GitHub Actions that deploys the entire solution to Azure by settings up a few GitHub secrets in your cloned repo.<\/p>\n<p>In addition to just running the apps, you can also <a href=\"https:\/\/github.com\/microsoft\/dotnet-podcasts\/tree\/main\/docs\/demos\">step-by-step demo directions<\/a> for any of the demos at .NET Conf. <\/p>\n<p>We will be continuing to add new features to the app and are also interested in what you are interested in seeing or what you are building with this sample architecture. Head over to the <a href=\"https:\/\/github.com\/microsoft\/dotnet-podcasts\/discussions\">GitHub discussions<\/a> to let us know.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The .NET Podcast app is a sample application showcasing .NET, ASP.NET Core, Blazor, .NET MAUI, Azure Container Apps, Orleans, and more. Pull down the source code and explore the architecture today.<\/p>\n","protected":false},"author":544,"featured_media":43991,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[685,7233,197,7509,327,7689,7237],"tags":[7611,7207,7698],"class_list":["post-43731","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-maui","category-aspnet","category-aspnetcore","category-azure","category-cloud-native","category-containers","tag-dotnet-7","tag-net-conf","tag-sample-app"],"acf":[],"blog_post_summary":"<p>The .NET Podcast app is a sample application showcasing .NET, ASP.NET Core, Blazor, .NET MAUI, Azure Container Apps, Orleans, and more. Pull down the source code and explore the architecture today.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/43731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/544"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=43731"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/43731\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/43991"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=43731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=43731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=43731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}