Deploying a .NET Core Application in Azure Kubernetes
Tags: csharp, dotnet, azure, webdev
Published: 2022-11-11 13:35:14

---
title: Deploying a .NET Core Application in Azure Kubernetes
published: true
date: 2022-11-10 12:43:53 UTC
tags: csharp, dotnet, azure, webdev
canonical_url: https://www.syncfusion.com/blogs/post/deploying-a-net-core-application-in-azure-kubernetes.aspx
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v54ee43a2fscv1d8ak0h.png
---

In development, maintaining the release and deployment workflow is one of the most critical areas of a project. Therefore, many teams like to create an automated deployment workflow to manage their releases and production. Maintaining an automated deployment workflow can be complex, but it will save the team time and effort.

Azure DevOps is one of the best platforms to create an automated CI/CD pipeline for an application, making this job easy. This article will discuss the steps to deploy a .NET Core application in Azure Kubernetes using the Azure DevOps Starter.

## Prerequisites

- [Azure subscription](https://azure.microsoft.com/en-in/free/search/ "Microsoft Azure Subscription")
- [GitHub account](https://github.com/join "GitHub repository")
- [.NET 6 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/6.0 "Download .NET 6 SDK")
- [Visual Studio 2022](https://visualstudio.microsoft.com/vs/ "Download Visual Studio 2022")

## What Are Containers and Container Orchestration?

To understand the functionality of Kubernetes, you must first understand the concepts of containers and container orchestration.

Containers are a form of the virtualized operating system. A container contains all essential executables, binary code, dependencies, and configuration files. A single container can execute anything from a microservice or software process to a considerably large application.

Containers seem to be very scalable since they can be produced as needed. But the complexity increases when you must maintain hundreds or thousands of containers, and it becomes impossible to manage all their lifecycles. This is the situation in which container orchestration comes to the rescue.

Containers’ maintenance, deployment, scaling, and networking can be automated using a container orchestration system. In addition, you can deploy the same application across multiple environments using container orchestration rather than having to redevelop or redesign it.

## What Is Kubernetes?

Kubernetes, also known as K8s, is a well-known open-source container management (orchestration) technology for automating applications’ deployment, scaling, and administration.

The Kubernetes orchestration features allow the development of application services that span across many containers, the scheduling of containers in a cluster, the deployment of those containers, and control of the status of the containers over time.

## What Is Azure Kubernetes Service?

Developed on top of the open-source Kubernetes technology, Azure Kubernetes Service (AKS) is a managed container orchestration service. You can use AKS to administer your hosted Kubernetes environment and easily launch, scale, and manage containerized apps.

Through on-demand resource provisioning, updating, and scaling, AKS simplifies Kubernetes deployment and operation. It enables you to execute your applications in the cloud while eliminating the complexity and operational burden of Kubernetes management.

In addition, your development and operations teams can collaborate on a single platform using AKS to build and deploy applications more efficiently.

## How to Deploy a .NET Core Application in Azure Kubernetes

### Step 1: Create an Azure DevOps starter project.

Sign in to your [Azure portal](https://azure.microsoft.com/en-us/get-started/azure-portal "Azure portal login page"), click the **Create a resource** option, and select **DevOps Starter**. Then, you’ll be navigated to where you can create the DevOps Starter project. You have to complete four main steps to create the project.

#### a. Choose the runtime.

Select the .NET runtime, as shown in the following figure, to run the ASP.NET Core application

![Choose the .NET option](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/Choose-the-runtime..png)

#### b. Choose the framework.

Select ASP.NET Core as the framework for the runtime, as shown in the following figure.

![Choose ASP.NET Core as the framework](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/DevOps-Starter-UI-framework-manu.png)

#### c. Choose the service.

Then, select Kubernetes as the Azure service to deploy this application.

![Choose Kubernetes as the Azure Service](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/Choose-the-service.png)

#### d. Create the project with the necessary configurations.

Now, configure the Azure subscription and settings for the Kubernetes cluster. I will explain these configurations in the upcoming step.

### Step 2: Configure the subscription and Azure Kubernetes service.

We need to do a few configurations in the fourth part of creating the DevOps Starter project. We’ll use GitHub to create a repository for this project. As shown in the following figure, you need to authorize access to Azure for your GitHub personal account.

![Authorize access to Azure for your GitHub personal account](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/Configure-the-subscription.png)

There are some other configurations to be done after authorizing the GitHub account. First, select the organization. Here, selects your GitHub account as a personal account. There is a field named Repository in the next figure: use it to add the name of the repository to be created in the GitHub account. This repository will be used to deploy the Azure Kubernetes service. Then, select the subscription for the DevOps Starter project. I will be using the **Azure for Students** subscription for this demonstration.

![Select the repository and subscription for the DevOps Starter project](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/Picture26.png)

Then, create a new cluster or use one you have already created.

If you are going to create a new cluster for this project, first add a name for the cluster. Then, select the location in which to create this service. After, select **Standard\_B2ms** , based on the B-series burstable VMs, as the virtual machine size. Use this VM to create the service for testing and demonstration purposes.

Add additional settings if you need them according to your requirements or subscription plan. For example, if you are using a student subscription, you can adjust the settings as shown in the following image.

![Additional Settings dialog](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/Additional-Settings.png)

The student subscription has some limitations. You have to set the node count to 1 and choose the **Basic** service tier for the Container Registry SKU, as it is a cost-optimized tier suitable for learning and testing purposes.

Finally, click **Review+Create** to create the Azure DevOps Starter project, which will deploy the ASP.NET Core application in the Azure Kubernetes service. It will take a few minutes to create the project.

After a few minutes, check your GitHub repository to make sure a new repository was created with the name you provided. You can see the workflow that has been automatically created for the GitHub action. It will be used to automate the CI/CD pipeline. You can also customize it if needed.

![Workflow added for the newly created GitHub repository](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/Workflow-added-for-the-newly-created-GitHub-repository.png)
The Azure resources and the status of the GitHub workflow will also be visible in the Azure portal after deploying it to the Kubernetes service, as shown in the following image.

![Azure portal displaying the Azure resources and the status of the GitHub workflow](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/Azure-portal-displaying-the-Azure-resources-and-the-status-of-the-GitHub-workflow.png)

Furthermore, you can access the ASP.NET Core application using the external endpoint. There, you will see the application as shown in the following figure.

![Accessing ASP.NET Core app using external endpoint](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/ASP.NET-Core-application.png)

### Step 3: Check the CI/CD pipeline.

Now, check the CI/CD pipeline you created using the Azure DevOps Starter by cloning the ASP.NET Core project to your local machine with the help of the following git command.

```bash
git clone {git-repo-link}.git 
```

For the ease of viewing and editing files, let’s use Visual Studio Code 2022 to open the cloned application. Then, open the file named **index.html** inside the **Pages** folder.

Then, you can edit it as you need. To demonstrate how the changes will activate the CI/CD pipeline, let’s change the<div class= “content-body”> div element as shown in the following code snippet.

```xml
<div class="content-body">
   <div class="success-text">Success!</div>
   <div class="description line-1">GitHub workflow has been successfully setup</div>
   <div class="description line-2">Deploying DotNet Core Application In Azure Kubernetes</div>
</div>

```

Then, run and check it locally. After that, push the latest changes with a commit. First, add the changes to the staging area.

```bash
git add 
```

Second, commit the changes with an appropriate commit message into the local repository.

```bash
git commit -m "Update index.html" 
```

Third, push the commits to the GitHub repository.

```bash
git push -u origin main 
```

The GitHub action will trigger the build pipeline after successfully pushing the commits.

![GitHub action triggering the build pipeline after pushing the commits](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/GitHub-action-triggering-the-build-pipeline-after-pushing-the-commits.png)
After completing the build process, it will deploy the application to the Azure Kubernetes service.

![Deploying the ASP.NET Core app to the Azure Kubernetes service](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/Deploying-the-ASP.NET-Core-app-to-the-Azure-Kubernetes-service.png)
You can check your Azure Kubernetes service after deploying the application to it by clicking the external endpoint, as shown in the following figure.

![Click on the external endpoint to access the deployed app](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/Click-on-the-external-endpoint-to-access-the-deployed-app.png)

Here, you see that the latest version of the application was deployed successfully to the Azure Kubernetes service.

![Deploying ASP.NET Core app in Azure Kubernetes](https://www.syncfusion.com/blogs/wp-content/uploads/2022/11/Deploying-ASP.NET-Core-app-in-Azure-Kubernetes.png)

## Conclusion

This article discussed how to deploy an ASP.NET Core app to the Azure Kubernetes service using the Azure DevOps Starter, with the help of GitHub actions, to create an automated CI/CD pipeline for the app. This process eliminates the complexity of the deployment process significantly.

I hope this article will help you in your next project.

The Syncfusion [ASP.NET Core UI control](https://www.syncfusion.com/aspnet-core-ui-controls "Syncfusion ASP.NET Core UI Controls") library, powered by [Essential JS 2](https://www.syncfusion.com/javascript-ui-controls "Essential JS 2 UI controls"), is the only suite you will ever need to build an app. It contains over 70 high-performance, lightweight, modular, and responsive UI controls in a single package. Use them to build stunning web apps!

If you’re already a Syncfusion user, you can download the [product setup](https://www.syncfusion.com/account/downloads/studio/ "License and download page of Essential Studio") . If not, you can download a free [30-day trial ](https://www.syncfusion.com/downloads "Free evaluation of the Syncfusion Essential Studio")to evaluate our products.

You can contact us through our [support forum](https://www.syncfusion.com/forums "Syncfusion support forum"), [support portal](https://support.syncfusion.com/ "Syncfusion support portal"), or [feedback portal](https://www.syncfusion.com/feedback/ "Syncfusion Feedback Portal"). As always, we are happy to assist you!

Thank you for reading!

## Related blogs

- [Handling CSV Files in ASP.NET Core Web APIs](https://www.syncfusion.com/blogs/post/handling-csv-files-in-asp-net-core-web-apis.aspx "Blog: Handling CSV Files in ASP.NET Core Web APIs")
- [Simple Steps to Integrate a Blazor WebAssembly Project with an Existing ASP.NET Core Application](https://www.syncfusion.com/blogs/post/integrate-blazor-webassembly-in-asp-net-core-application.aspx "Blog: Simple Steps to Integrate a Blazor WebAssembly Project with an Existing ASP.NET Core Application")
- [Creating an ASP.NET Core CRUD Web API with Dapper and PostgreSQL](https://www.syncfusion.com/blogs/post/creating-an-asp-net-core-crud-web-api-with-dapper-and-postgresql.aspx "Blog: Creating an ASP.NET Core CRUD Web API with Dapper and PostgreSQL")
- [Authentication Support in Syncfusion ASP.NET Core Project Template: An Overview](https://www.syncfusion.com/blogs/post/authentication-support-in-syncfusion-asp-net-core-project-template-an-overview.aspx "Blog: Authentication Support in Syncfusion ASP.NET Core Project Template")