Skip to content

This repository provides a simple example of a microservice architecture using a Microsoft .NET solution with MariaDB

License

Notifications You must be signed in to change notification settings

mariadb-developers/microservices-dotnet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microservice Example using .NET and MariaDB

This repository provides a simple example of a microservice architecture using a Microsoft .NET solution with Entity Framework and MariaDB that contains:

  • Two microservice (Web API) projects
  • One API Gateway project

Table of Contents

  1. Requirements
  2. Introduction to MariaDB
    1. MariaDB
    2. MariaDB in the cloud
  3. Getting started
    1. Get the code
    2. Create the schema
    3. Anatomy of the app
    4. Confifgure the application
    5. Build and run the app
  4. Helpful Resources
  5. Support and contribution
  6. License

Requirements

This sample application will require the following to be installed on your machine:

Introduction to MariaDB

MariaDB

MariaDB Platform integrates transactional and analytical products so developers can build modern applications by enriching transactions with real-time analytics and historical data, creating insightful experiences and compelling opportunities for customers – and for businesses, endless ways to monetize data.

To get started using MariaDB locally you can choose one of the following options:

MariaDB in the cloud

SkySQL is the first and only database-as-a-service (DBaaS) to bring the full power of MariaDB Platform to the cloud, including its support for transactional, analytical and hybrid workloads. Built on Kubernetes, and optimized for cloud infrastructure and services, SkySQL combines ease of use and self-service with enterprise reliability and world-class support – everything needed to safely run mission-critical databases in the cloud, and with enterprise governance.

Get started with SkySQL!

Get started

In order to run the TODO application you will need to have a MariaDB instance to connect to. For more information please check out "Get Started with MariaDB".

Get the code

Download this code directly or use git (through CLI or a client) to retrieve the code using git clone:

$ git clone https://github.com/mariadb-corporation/dev-example-microservices-dotnet.git

Create the schema

Connect to the database and execute the following SQL scripts using the following options:

1.) Using the MariaDB command-line client to execute the SQL contained within schema.sql.

Example command:

$ mariadb --host HOST_ADDRESS --port PORT_NO --user USER --password PASSWORD < schema.sql

2.) Copying, pasting and executing the scripts contained in schema.sql using a client of your choice.

CREATE DATABASE customer_db;

 CREATE TABLE customer_db.`customers` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `email` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

CREATE DATABASE product_db;

CREATE TABLE product_db.`products` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `description` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

Anatomy of the app

This application is made of three parts:

  • Customers.API - a .NET 6 REST project that uses Entity Framework 6 to connect to and communicate with an underlying MariaDB database.
  • Products.API - a .NET 6 REST project that uses Entity Framework 6 to connect to and communicate with an underlying MariaDB database.
  • Gateway.API - a .NET project that uses Ocelot to function as an API gateway for the Customers.API and Products.API microservices.

Confifgure the application to use your MariaDB database

For the Customers.API and Products.API microservice projects to use your MariaDB database they must first be configured. The projects already contain connection strings, but depending on your setup you may need to update them.

To do that, update the connection string configuration in the projects' appsettings.json files:

Build and run the app

Depending on how you've setup your environment you may have the option to build and run .NET solutions using:

Helpful Resources

Webinar: Creating Microservices with .NET 6, Entity Framework and MariaDB

Support and Contribution

Please feel free to submit PR's, issues or requests to this project project directly.

If you have any other questions, comments, or looking for more information on MariaDB please check out:

Or reach out to us diretly via:

License

License

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%