103
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications
Figure 6-5. Simple data-driven/CRUD microservice design
The previous diagram shows the logical Catalog microservice, that
includes its Catalog database,
which can be or not in the same Docker host. Having the database in the same Docker host might be
good for development, but not for production. When you are developing this kind of service, you only
need
ASP.NET Core
and a data-access API or ORM like
Entity Framework Core
. You could also
generate
Swagger
metadata
automatically through
Swashbuckle
to provide a description of what your
service offers, as explained in the next section.
Note that running a database server like SQL Server within a Docker container is great for
development environments, because you can have all your dependencies
up and running without
needing to provision a database in the cloud or on-premises. This approach is convenient when
running integration tests. However, for production environments, running a database server in a
container is not
recommended, because you usually do not get high availability with that approach.
For a production environment in Azure, it is recommended that you use Azure SQL DB or any other
database technology that can provide high availability and high scalability. For example,
for a NoSQL
approach, you might choose CosmosDB.
Finally, by editing the Dockerfile and docker-compose.yml metadata files, you can configure how the
image of this container will be created
—
what base image it will use, plus design settings such as
internal and external names and TCP ports.
Dostları ilə paylaş: