dmakeroam / dotnet-core-web-api-dapr

dotnet-core-web-api-dapr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Develop on Okteto

.NET Core Web API Starter Project

This is a boilerplate template for building / deploying a .NET Core Web API microservice on Kubernetes / Azure Container Instance. This leverages .NET 6, new hosting model, and new routing API to enhance .NET performance. You can learn .NET 6 more on ASP.NET Core minimal APIs.

Versioning

GitHub Release .NET Core Version Diagnostics HealthChecks Version
main 6.0.100-preview.6.21355.2 2.2.0

Project Structure

├── Controllers
│   └── KubeOpsController.cs
├── Dockerfile
├── KubernetesLocalProcessConfig.yaml
├── LICENSE
├── Models
│   └── DatabaseConfig.cs
├── Program.cs
├── Properties
│   └── launchSettings.json
├── README.md
├── Services
│   └── APIService.cs
├── Startup.cs
├── appsettings.Development.json
├── bin
│   └── Debug
├── configs
│   └── prod
├── dotnet-core-web-api.csproj
├── dotnet-core-web-api.sln
├── manifests
│   ├── deployment.yaml
│   └── service.yaml
  • Dockerfile is .NET Core Web API Multistage Dockerfile (following Docker Best Practices)
  • KubernetesLocalProcessConfig.yaml is Bridge to Kubernetes config to supports developing .NET Core Web API microservice on Kubernetes
  • configs folder will contain .NET Core Web API centralized config structure
  • appsettings.Development.json is .NET Core Web API development environment config
  • manifests folder will contain Kubernetes manifests (deployment, service)
  • Startup.cs is .NET Core Web API startup & path routing config
  • Program.cs is .NET Core Web API environment variable mapping config

Setting Up

To setup this project, you need to clone the git repo

$ git clone https://github.com/kubeopsskills/dotnet-core-web-api.git
$ cd dotnet-core-web-api

followed by

$ dotnet restore

Deploying a .NET Core Web API microservice on Kubernetes

Prerequisite:

  • .NET Core Web API Docker Image

Preparing Config Map for .NET Core Web API microservice

$ kubectl apply -k configs/prod

To deploy the microservice on Kubernetes, run following command:

$ kubectl apply -f manifests

This will deploy it on Kubernetes with the centralized config.

Deploying a .NET Core Web API microservice on Azure Container Instance (ACI)

Prerequisite:

To deploy the microservice on ACI, run following command:

$ docker compose -f aci-docker-compose.yaml up -d

Deploying a .NET Core Web API microservice on AWS App Runner using AWS Copilot

Prerequisite:

To deploy the microservice on AWS, following these steps:

  • Prepare AWS IAM roles and AWS ECR repository for the microservice
$ copilot init --app kubeops-demo
  • Create the test environment on AWS
$ copilot env init --name test --app kubeops-demo
  • Deploy the microservice on the test environment
$ copilot svc deploy --env test

Learning Resources:

About

dotnet-core-web-api-dapr

License:MIT License


Languages

Language:C# 85.0%Language:Dockerfile 15.0%