262
CHAPTER 6 | Tackle Business Complexity in a Microservice with DDD and CQRS Patterns
However, if you are planning to use MongoDB API to access Azure Cosmos
DB in Azure for
production applications, you should analyze the differences in capabilities
and performance when
using MongoDB API to access Azure Cosmos DB databases compared to using the native Azure
Cosmos DB API. If it is similar you can use MongoDB API and you get the benefit of supporting two
NoSQL database engines at the same time.
You could also use MongoDB clusters as the production database in Azure’s cloud, too, with
MongoDB Azure Service
. But that is not a PaaS service provided by Microsoft. In this case,
Azure is just
hosting that solution coming from MongoDB.
Basically, this is jus
t a disclaimer stating that you shouldn’t always use MongoDB API
against Azure
Cosmos DB, as we did in eShopOnContainers because it was a convenient choice for Linux containers.
The decision should be based on the specific needs and tests you need to do for your production
application.
The code: Use MongoDB API in .NET applications
MongoDB API for .NET is based on NuGet packages that you need to add
to your projects, like in the
Locations.API project shown in the following figure.
263
CHAPTER 6 | Tackle Business Complexity in a Microservice with DDD and CQRS Patterns
Figure 7-22. MongoDB API NuGet packages references in a .NET project
Let’s investigate the code in the following sections.
Dostları ilə paylaş: