Git Product home page Git Product logo

dev-example-microservices-dotnet's Introduction

Microservice Example using .NET and MariaDB

⚠️ [UNMAINTAINED] This repository has been moved and is currently maintained here. ⚠️


This repository provides a simple example of a microservice architecture using a Microsoft .NET solution 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. Requirements to run the app
  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:

Support and Contribution

Thanks so much for taking a look at this sample app! As this is a simple example, there's plenty of potential for improvement and customization. Please feel free to submit PR's to the project to include your modifications!

If you have any questions, comments, or would like to contribute to this or future projects like this please reach out to us directly at [email protected] or on Twitter.

License

License

dev-example-microservices-dotnet's People

Contributors

rhedgpeth avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.