Blog

Blog posts on .NET, Azure, and more.

API Versioning with ASP.NET Core 6.0 Minimal APIs

August 11, 2022 by Anuraj

AspNetCore DotNetCore MinimalApi

This post is about how to implement api versioning in ASP.NET Core 6.0 Minimal APIs. Earlier Minimal APIs versioning was not supported. Recently ASP.NET Core team introduced versioning in ASP.NET Core Minimal APIs. To implement it, first we need to create a Web API with Minimal API - we need .NET 6.0 or more to do this. Since I installed .NET 7 Preview versions, I am using the --framework version parameter. We can create web api with the command like this - dotnet new webapi -o WeatherForecastApi -minimal --framework net6.0. Once it is done, we need to add reference of Asp.Versioning.Http version 6.0.0-preview.3 using the command dotnet add package Asp.Versioning.Http --version 6.0.0-preview.3.

Creating your first Azure Container App

August 08, 2022 by Anuraj

Azure Docker Container

This post is about what is azure container app and how to deploy a docker image to azure container app. The Azure Container Apps service enables you to run microservices and containerized applications on a serverless platform. First we can search for Container App in the search box - and select the Container App and click on the card.

Mount your Azure Cloud Shell to another Storage Account

August 05, 2022 by Anuraj

Azure CloudShell Storage Account

This post is about switching or mounting the Azure Cloud shell to another storage account. We are using Azure Cloud Shell for deploying our SQL Scripts using a PowerShell. First we will upload the script to the storage account file share and then we will execute some Powershell scripts for the deployment.

Unit Testing ASP.NET Core Minimal APIs

July 25, 2022 by Anuraj

AspNetCore UnitTesting WebApi

This post is about implementing unit testing ASP.NET Core Minimal APIs. This feature is only available in .NET Core 7 Preview. If you’re using .NET Core 6. This will not work. So first you need to install the .NET 7 preview. For the demo I am using this 7.0.100-preview.6.22352.1 version. Once it is done, we need to create a solution, web api with minimal api support and xunit test. Here are the commands.

Custom scaffold templates in ASP.NET Core

July 20, 2022 by Anuraj

AspNetCore VisualStudio

This post is about customizing the scaffold templates controllers and views in ASP.NET Core. We can achieve this by simply modifying the templates in this folder - %USERPROFILE%\.nuget\packages\microsoft.visualstudio.web.codegenerators.mvc\6.0.6\Templates (the number 6.0.6 will change based on the SDK version) - but if we modify the template files in this folder it will impact the whole system and we can’t share the templates with other developers. So we can create a folder with name Templates in the ASP.NET Core MVC project - while scaffolding, Visual Studio and dotnet-aspnet-codegenerator global tool will first check this folder in your project and if it is available it will use the templates from this folder.

Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub