From the course: Azure Microservices with .NET Core for Developers

Creating a .NET Core solution for microservices - Azure Tutorial

From the course: Azure Microservices with .NET Core for Developers

Start my 1-month free trial

Creating a .NET Core solution for microservices

- [Man] In this video, we will create the solution for our microservices. Okay, let's open Visual Studio and go ahead and click on File, New Project and in this dialog box, search for Blank Solution. This is the template for solutions that have nothing on it. Then, we're going to click on the Next button and here, I'm going to choose another location for this solution. This is going to be course inside my C Drive. And for the solution name, we're going to choose ECommerce. And finally, I will click on the Create button. So, we have this empty solution right now and let's go ahead and right-click on this solution and select Add New Project because we're going to create each project for each microservice. So, the template that we're going to use is this ASP.NET Core Web Application template. I'm going to select this from the Recent Project Templates. If you don't have this on your left side, you can just search for ASP.NET and you will find this template in the list. So, let's select this and next we're going to choose the first project name. This is going to be Ecommerce.Api.Products. This is the project for the products microservice. And finally, I'm going to click Create. In this other dialog, I have to choose which kind of template I want to use for this ASP.NET Core Application. In this case, I'm going to select API and be sure to uncheck this Configure for HTTPS option because in this moment, it won't be required. So, finally, we're going to click on the Create button and we're going to wait until this project is created. So I have this project right now and let's go ahead and do the same for the customer's microservice. So, I'm going to choose ASP.NET Core Web Application and for the name, I'm going to choose ECommerce.Api.Customers. API again, uncheck, Create. Also, for the orders microservice, Ecommerce, Api, Orders API, uncheck, Create. And finally, for the search microservice. Next, Ecommerce, Api, Search API, uncheck, Create. So, in this moment, we have this solution with four projects. The first microservice that I'm going to implement is this one, the Products Microservice. So, be sure to delete the weather forecast file also the weather forecast controller. Those files were added by the template but we're not going to use them so it's perfectly safe if we delete those files. So, let's do the same for the weather forecast controller inside the ECommerce API customer's project and also orders and search. Okay, so, I'm going to close all documents so we have this clean interface right now. So, in this API products project, let's go ahead and right click on the Dependencies option so we can select this Manage NuGet Packages option. And in this panel, we're going to add three NuGet Packages for this project. The first one is going to be Microsoft Entity Framework Core. This is the NuGet Package for the Entity Framework Core that we're going to use as the data access technology for this microservice. Let's go ahead and click on the Install button and accept this license. And next, we're going to install Microsoft Entity Framework Core in memory. This is very important because, for this particular scenario, we're not going to use a relation of database. We're going to use in-memory database because of time constraints. So, let's go ahead and click on the install button again. And finally, another NuGet Package that we're going to use is Automapper. We're going to use this framework for mapping the objects from the DB context to the models that we're going to expose from the microservices. So, AutoMapper.Extensions.Microsoft.DependencyInjection is the name. Dependency Injection. Right, this is the name of the NuGet Package that we're going to use. And let's click on the Do Not Show This Again and finally accept. All right, so, if I right-click on the project and choose the rebuild option, of course we don't have any kind of code in this moment, but we are ready to implement the logic for this products microservice.

Contents