Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 9b21ac1

Browse files
author
Ramón Tomás
committed
Merge dev
2 parents e3f8ac6 + de6f9e6 commit 9b21ac1

File tree

11 files changed

+25
-40
lines changed

11 files changed

+25
-40
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ The **dockerfiles** in the solution have also been updated and now support [**Do
1717
>**PLEASE** Read our [branch guide](./branch-guide.md) to know about our branching policy
1818
1919
> ### DISCLAIMER
20-
> **IMPORTANT:** The current state of this sample application is **BETA**, because we are constantly evolving towards new released technologies. Therefore, many areas could be improved and change significantly while refactoring current code and implementing new features. Feedback with improvements and pull requests from the community will be highly appreciated and accepted.
20+
> **IMPORTANT:** The current state of this sample application is **BETA**, because we are constantly evolving towards newly released technologies. Therefore, many areas could be improved and change significantly while refactoring the current code and implementing new features. Feedback with improvements and pull requests from the community will be highly appreciated and accepted.
2121
>
22-
> This reference application proposes a simplified microservice oriented architecture implementation to introduce technologies like .NET Core with Docker containers through a comprehensive application. The chosen domain is an eShop/eCommerce but simply because it is a well-know domain by most people/developers.
23-
However, this sample application should not be considered as an "eCommerce reference model", at all. The implemented business domain might not be ideal from an eCommerce business point of view. It is neither trying to solve all the problems in a large, scalable and mission-critical distributed system. It is just a bootstrap for developers to easily get started in the world of Docker containers and microservices with .NET Core.
22+
> This reference application proposes a simplified microservice oriented architecture implementation to introduce technologies like .NET Core with Docker containers through a comprehensive application. The chosen domain is eShop/eCommerce but simply because it is a well-known domain by most people/developers.
23+
However, this sample application should not be considered as an "eCommerce reference model" at all. The implemented business domain might not be ideal from an eCommerce business point of view. It is neither trying to solve all the problems in a large, scalable and mission-critical distributed system. It is just a bootstrap for developers to easily get started in the world of Docker containers and microservices with .NET Core.
2424
> <p>For example, the next step after running the solution in the local dev PC and understanding Docker containers and microservices development with .NET Core, is to select a microservice cluster/orchestrator like Kubernetes in Azure (AKS) or Azure Service Fabric, both environments tested and supported by this solution.
25-
> Additional steps would be to move your databases to HA cloud services (like Azure SQL Database), or switch your EventBus to use Azure Service Bus (instead of bare-bone RabbitMQ) or any other production ready Service Bus in the market.
25+
> Additional steps would be to move your databases to HA cloud services (like Azure SQL Database) or switch your EventBus to use Azure Service Bus (instead of bare-bone RabbitMQ) or any other production-ready Service Bus in the market.
2626
2727
![image](https://user-images.githubusercontent.com/1712635/40397331-059a7ec6-5de7-11e8-8542-a597eca16fef.png)
2828

@@ -39,7 +39,7 @@ The architecture proposes a microservice oriented architecture implementation wi
3939
> ### Important Note on API Gateways and published APIs
4040
> Since April 2018, we have introduced the implementation of the [API Gateway pattern](http://microservices.io/patterns/apigateway.html) and [Backend-For-Front-End (BFF) pattern](https://samnewman.io/patterns/architectural/bff/) in eShopOnContainers architecture, so you can filter and publish simplified APIs and URIs and apply additional security in that tier while hiding/securing the internal microservices to the client apps or outside consumers. These sample API Gateways in eShopOnContainers are based on [Ocelot](https://github.com/ThreeMammals/Ocelot), an OSS lightweight API Gateway solution explained [here](http://threemammals.com/ocelot). The deployed API Gateways are autonomous and can be deployed as your own custom microservices/containers, as it is currently done in eShopOnContainers, so you can test it even in a simple development environment with just Docker engine or deploy it into orchestrators like Kubernetes in AKS or Service Fabric.
4141
42-
> For your production-ready architecture you can either keep using [Ocelot](https://github.com/ThreeMammals/Ocelot) which is simple and easy to use and used in production by significant companies or if you need further functionality and a much richer set of features suittable for commercial APIs, you can also substitute those API Gateways and use [Azure API Management](https://azure.microsoft.com/en-us/services/api-management/) or any other commercial API Gateway, as shown in the following image.
42+
> For your production-ready architecture you can either keep using [Ocelot](https://github.com/ThreeMammals/Ocelot) which is simple and easy to use and used in production by significant companies or if you need further functionality and a much richer set of features suitable for commercial APIs, you can also substitute those API Gateways and use [Azure API Management](https://azure.microsoft.com/en-us/services/api-management/) or any other commercial API Gateway, as shown in the following image.
4343
4444
<p>
4545
<img src="img/eShopOnContainers-Architecture-With-Azure-API-Management.png">
@@ -56,9 +56,9 @@ The architecture proposes a microservice oriented architecture implementation wi
5656
<p>
5757
5858
> ### Important Note on Database Servers/Containers
59-
> In this solution's current configuration for a development environment, the SQL databases are automatically deployed with sample data into a single SQL Server container (a single shared Docker container for SQL databases) so the whole solution can be up and running without any dependency to any cloud or specific server. Each database could also be deployed as a single Docker container, but then you'd need more than 8GB of RAM assigned to Docker in your development machine in order to be able to run 3 SQL Server Docker containers in your Docker Linux host in "Docker for Windows" or "Docker for Mac" development environments.
59+
> In this solution's current configuration for a development environment, the SQL databases are automatically deployed with sample data into a single SQL Server container (a single shared Docker container for SQL databases) so the whole solution can be up and running without any dependency to any cloud or a specific server. Each database could also be deployed as a single Docker container, but then you'd need more than 8GB of RAM assigned to Docker in your development machine in order to be able to run 3 SQL Server Docker containers in your Docker Linux host in "Docker for Windows" or "Docker for Mac" development environments.
6060
> <p> A similar case is defined in regard to Redis cache running as a container for the development environment. Or a No-SQL database (MongoDB) running as a container.
61-
> <p> However, in a real production environment it is recommended to have your databases (SQL Server, Redis, and the NO-SQL database, in this case) in HA (High Available) services like Azure SQL Database, Redis as a service and Azure CosmosDB instead the MongoDB container (as both systems share the same access protocol). If you want to change to a production configuration, you'll just need to change the connection strings once you have set up the servers in a HA cloud or on-premises.
61+
> <p> However, in a real production environment it is recommended to have your databases (SQL Server, Redis, and the NO-SQL database, in this case) in HA (High Available) services like Azure SQL Database, Redis as a service and Azure CosmosDB instead the MongoDB container (as both systems share the same access protocol). If you want to change to a production configuration, you'll just need to change the connection strings once you have set up the servers in an HA cloud or on-premises.
6262
6363
## Related documentation and guidance
6464
While developing this reference application, we've been creating a reference <b>Guide/eBook</b> focusing on <b>architecting and developing containerized and microservice based .NET Applications</b> (download link available below) which explains in detail how to develop this kind of architectural style (microservices, Docker containers, Domain-Driven Design for certain microservices) plus other simpler architectural styles, like monolithic apps that can also live as Docker containers.
@@ -76,12 +76,12 @@ Download in other formats (**eReaders** like **MOBI**, **EPUB**) and other eBook
7676

7777
7878

79-
However, we encourage to download and review the [Architecting and Developing Microservices eBook](https://aka.ms/microservicesebook) because the architectural styles and architectural patterns and technologies explained in the guidance are using this reference application when explaining many pattern implementations, so you'll understand much better the context, design and decisions taken in the current architecture and internal designs.
79+
However, we encourage you to download and review the [Architecting and Developing Microservices eBook](https://aka.ms/microservicesebook) because the architectural styles and architectural patterns and technologies explained in the guide are using this reference application when explaining many pattern implementations, so you'll understand the context, design and decisions taken in the current architecture and internal designs much better.
8080

8181
## Overview of the application code
8282
In this repo you can find a sample reference application that will help you to understand how to implement a microservice architecture based application using <b>.NET Core</b> and <b>Docker</b>.
8383

84-
The example business domain or scenario is based on an eShop or eCommerce which is implemented as a multi-container application. Each container is a microservice deployment (like the basket-microservice, catalog-microservice, ordering-microservice and the identity-microservice) which are developed using ASP.NET Core running on .NET Core so they can run either on Linux Containers and Windows Containers.
84+
The example business domain or scenario is based on an eShop or eCommerce which is implemented as a multi-container application. Each container is a microservice deployment (like the basket-microservice, catalog-microservice, ordering-microservice and the identity-microservice) which is developed using ASP.NET Core running on .NET Core so they can run either on Linux Containers and Windows Containers.
8585
The screenshot below shows the VS Solution structure for those microservices/containers and client apps.
8686

8787
- (*Recommended when getting started*) Open <b>eShopOnContainers-ServicesAndWebApps.sln</b> for a solution containing just the server-side projects related to the microservices and web applications.
27.1 MB
Binary file not shown.
5.55 MB
Binary file not shown.

src/Services/Basket/Basket.API/BasketSettings.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
public class BasketSettings
44
{
55
public string ConnectionString { get; set; }
6-
7-
public string EventBusConnection { get; set; }
86
}
97
}

src/Services/Basket/Basket.UnitTests/Basket.UnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="xunit" Version="2.3.1" />
1212
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
1313
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
14-
<PackageReference Include="MediatR" Version="4.1.0" />
14+
<PackageReference Include="MediatR" Version="5.1.0" />
1515
<PackageReference Include="Moq" Version="4.8.1" />
1616
</ItemGroup>
1717

src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
using Autofac;
2-
using Autofac.Core;
1+
using System.Linq;
2+
using System.Reflection;
3+
using Autofac;
34
using FluentValidation;
45
using MediatR;
56
using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands;
67
using Ordering.API.Application.Behaviors;
78
using Ordering.API.Application.DomainEventHandlers.OrderStartedEvent;
89
using Ordering.API.Application.Validations;
910
using Ordering.API.Infrastructure.Behaviors;
10-
using System.Collections.Generic;
11-
using System.Linq;
12-
using System.Reflection;
1311

1412
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules
1513
{
@@ -35,23 +33,12 @@ protected override void Load(ContainerBuilder builder)
3533
.AsImplementedInterfaces();
3634

3735

38-
builder.Register<SingleInstanceFactory>(context =>
36+
builder.Register<ServiceFactory>(context =>
3937
{
4038
var componentContext = context.Resolve<IComponentContext>();
4139
return t => { object o; return componentContext.TryResolve(t, out o) ? o : null; };
4240
});
4341

44-
builder.Register<MultiInstanceFactory>(context =>
45-
{
46-
var componentContext = context.Resolve<IComponentContext>();
47-
48-
return t =>
49-
{
50-
var resolved = (IEnumerable<object>)componentContext.Resolve(typeof(IEnumerable<>).MakeGenericType(t));
51-
return resolved;
52-
};
53-
});
54-
5542
builder.RegisterGeneric(typeof(LoggingBehavior<,>)).As(typeof(IPipelineBehavior<,>));
5643
builder.RegisterGeneric(typeof(ValidatorBehavior<,>)).As(typeof(IPipelineBehavior<,>));
5744
builder.RegisterGeneric(typeof(TransactionBehaviour<,>)).As(typeof(IPipelineBehavior<,>));

src/Services/Ordering/Ordering.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public async Task Invoke(HttpContext context)
6262
new Claim("emails", currentUserId),
6363
new Claim("name", "Test user"),
6464
new Claim("nonce", Guid.NewGuid().ToString()),
65-
new Claim("ttp://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"),
65+
new Claim("http://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"),
6666
new Claim("nonce", Guid.NewGuid().ToString()),
6767
new Claim("sub", "1234"),
6868
new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"),

src/Services/Ordering/Ordering.API/Ordering.API.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
<ItemGroup>
3333
<PackageReference Include="FluentValidation.AspNetCore" Version="7.5.0" />
34-
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="4.1.0" />
34+
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="5.1.0" />
3535
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.1" />
3636
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />
3737
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
@@ -40,7 +40,7 @@
4040
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.1.0" />
4141
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.1.0" />
4242
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" />
43-
<PackageReference Include="MediatR" Version="4.1.0" />
43+
<PackageReference Include="MediatR" Version="5.1.0" />
4444
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
4545
<PackageReference Include="System.Reflection" Version="4.3.0" />
4646
<PackageReference Include="Dapper" Version="1.50.4" />

src/Services/Ordering/Ordering.Domain/AggregatesModel/OrderAggregate/Address.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
66
{
77
public class Address : ValueObject
88
{
9-
public String Street { get; }
10-
public String City { get; }
11-
public String State { get; }
12-
public String Country { get; }
13-
public String ZipCode { get; }
9+
public String Street { get; private set; }
10+
public String City { get; private set; }
11+
public String State { get; private set; }
12+
public String Country { get; private set; }
13+
public String ZipCode { get; private set; }
1414

1515
private Address() { }
1616

src/Services/Ordering/Ordering.Domain/Ordering.Domain.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="MediatR" Version="4.0.1" />
9-
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="4.0.0" />
8+
<PackageReference Include="MediatR" Version="5.1.0" />
9+
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="5.1.0" />
1010
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.4.0" />
1111
</ItemGroup>
1212

0 commit comments

Comments
 (0)