title
stringlengths 3
46
| content
stringlengths 0
1.6k
|
---|---|
11:509
|
image specifies where to take the image from. In our case, the image is contained in a public Docker registry.
|
11:510
|
environment specifies the environment variables that are needed by SQL Server – that is, the administrator password, the acceptance of a SQL Server license, and the SQL Server edition.
|
11:511
|
As usual, ports specify the port mappings.
|
11:512
|
docker-compose.override.yml is used to run the images from within Visual Studio.
|
11:513
| |
11:514
|
If you need to specify parameters for either the production environment or the testing environment, you can add further docker-compose-xxx.override.yml files, such as docker-compose-staging.override.yml and docker-compose-production.override.yml, and then launch them manually in the target environment with something like the following code:
|
11:515
|
docker-compose -f docker-compose.yml -f docker-compose-staging.override.yml up
|
11:516
| |
11:517
|
Then, you can destroy all the containers with the following code:
|
11:518
|
docker-compose -f docker-compose.yml -f docker-compose.staging.yml down
|
11:519
| |
11:520
|
While docker-compose has a limited capability when it comes to handling node clusters, it is mainly used in testing and development environments. For production environments, more sophisticated tools, called orchestrators, are needed. A de facto standard for the production environment is Kubernetes, which will be analyzed in detail in Chapter 20, Kubernetes.
|
11:521
|
Azure and Visual Studio support for microservice orchestration
|
11:522
|
Visual Studio has extensions for debugging a single microservice while it communicates with other microservices deployed in Kubernetes.
|
11:523
|
Also available are tools for testing and debugging several communicating microservices in the development machine and for deploying them automatically on Azure Kubernetes Service with just minimal configuration information.
|
11:524
|
All Visual Studio tools for Kubernetes and the whole process of developing for Kubernetes with Visual Studio will be described in the practical example in Chapter 22, Developing .NET Microservices for Kubernetes.
|
11:525
|
Moving on from Visual Studio’s features for Kubernetes, let’s dive into the key tools offered, in general, by all microservices orchestrators like Kubernetes.
|
11:526
|
Which tools are needed to manage microservices?
|
11:527
|
Effectively handling microservices in your CI/CD cycles requires both a private Docker image registry and a state-of-the-art microservice orchestrator that’s capable of doing the following:
|
11:528
| |
11:529
|
Allocating and load-balancing microservices on available hardware nodes
|
11:530
|
Monitoring the health state of services and replacing faulty services if hardware/software failures occur
|
11:531
|
Logging and presenting analytics
|
11:532
|
Allowing the designer to dynamically change requirements such as hardware nodes allocated to a cluster, the number of service instances, and so on
|
11:533
| |
11:534
|
The following subsection describes the Azure facilities we can use to store Docker images. The microservices orchestrators available in Azure are described in a dedicated chapter – namely, Chapter 20, Kubernetes.
|
11:535
|
Having learned about the essential functionalities offered by microservices orchestration, let’s now turn our attention to how Azure facilitates these processes, starting with the setup of a private Docker registry.
|
11:536
|
Defining your private Docker registry in Azure
|
11:537
|
Defining your private Docker registry in Azure is easy. Just type Container registries into the Azure search bar and select Container registries. On the page that appears, click on the Create button.
|
11:538
|
The following form will appear:
|
11:539
| |
11:540
|
Figure 11.9: Creating an Azure private Docker registry
|
11:541
|
The name you select is used to compose the overall registry URI: <name>.azurecr.io. As usual, you can specify the subscription, resource group, and location. The SKU dropdown lets you choose from various levels of offerings that differ in terms of performance, available memory, and a few other auxiliary features.
|
11:542
|
Whenever you mention image names in Docker commands or in a Visual Studio publish form, you must prefix them with the registry URI: <name>.azurecr.io/<my imagename>.
|
11:543
|
If images are created with Visual Studio, then they can be published by following the instructions that appear once you publish the project. Otherwise, you must use Docker commands to push them into your registry.
|
11:544
|
The easiest way to use Docker commands that interact with the Azure registry is by installing the Azure CLI on your computer. Download the installer from https://aka.ms/installazurecliwindows and execute it. Once the Azure CLI has been installed, you can use the az command from Windows Command Prompt or PowerShell. In order to connect with your Azure account, you must execute the following login command:
|
11:545
|
az login
|
11:546
| |
11:547
|
This command should start your default browser and should drive you through the manual login procedure.
|
11:548
|
Once logged in to your Azure account, you can log in to your private registry by typing the following command:
|
11:549
|
az acr login --name {registryname}
|
11:550
| |
11:551
|
Now, let’s say you have a Docker image in another registry. As a first step, let’s pull the image on your local computer:
|
11:552
|
docker pull other.registry.io/samples/myimage
|
11:553
| |
11:554
|
If there are several versions of the preceding image, the latest will be pulled since no version was specified. The version of the image can be specified as follows:
|
11:555
|
docker pull other.registry.io/samples/myimage:version1.0
|
11:556
| |
11:557
|
Using the following command, you should see myimage within the list of local images:
|
11:558
|
docker images
|
11:559
| |
11:560
|
Then, tag the image with the path you want to assign in the Azure registry:
|
11:561
|
docker tag myimage myregistry.azurecr.io/testpath/myimage
|
11:562
| |
11:563
|
Both the name and destination tag may have versions (:<version name>).
|
11:564
|
Finally, push it to your registry with the following command:
|
11:565
|
docker push myregistry.azurecr.io/testpath/myimage
|
11:566
| |
11:567
|
In this case, you can specify a version; otherwise, the latest version is pushed.
|
11:568
|
By doing this, you can remove the image from your local computer using the following command:
|
11:569
|
docker rmi myregistry.azurecr.io/testpath/myimage
|
11:570
| |
11:571
|
Summary
|
11:572
|
In this chapter, we described what microservices are and how they have evolved from the concept of a module. Then, we talked about the advantages of microservices and when it is worth using them, as well as general criteria for their design. We also explained what Docker containers are and analyzed the strong connection between containers and microservice architectures.
|
11:573
|
Then, we took on a more practical implementation by describing all the tools that are available in .NET so that we can implement microservice-based architectures. We also described infrastructures that are needed by microservices and how Azure offers both container registries and container orchestrators.
|
11:574
|
This chapter was just a general introduction to microservices. Further chapters will discuss most of the subjects introduced here in more detail while showing practical implementation techniques and code examples.
|
11:575
|
This ends the first part of the book dedicated to fundamentals. The next chapter, Choosing Your Data Storage in the Cloud, starts the second part of the book, which is dedicated to specific technologies.
|
11:576
|
Questions
|
11:577
| |
11:578
|
What is the two-fold nature of the module concept?
|
11:579
|
Is scaling optimization the only advantage of microservices? If not, list some further advantages.
|
11:580
|
What is Polly?
|
11:581
|
What Docker support is offered by Visual Studio?
|
11:582
|
What is an orchestrator, and what orchestrators are available on Azure?
|
11:583
|
Why is publisher/subscriber-based communication so important in microservices?
|
11:584
|
What is RabbitMQ?
|
11:585
|
Why are idempotent messages so important?
|
11:586
| |
11:587
|
Further reading
|
11:588
|
The following are links to the official documentation for Azure Service Bus, RabbitMQ, and other event bus technologies:
|
11:589
| |
11:590
|
Azure Service Bus: https://docs.microsoft.com/en-us/azure/service-bus-messaging/
|
11:591
|
NServiceBus: https://particular.net/nservicebus
|
11:592
|
MassTransit: https://masstransit-project.com/
|
11:593
|
Brighter: https://www.goparamore.io/
|
11:594
|
RabbitMQ: https://www.rabbitmq.com/getstarted.html
|
11:595
|
EasyNetQ: https://easynetq.com/
|
11:596
|
The following are also links for Polly and Docker:
|
11:597
|
The documentation for Polly, a tool for reliable communication/tasks, can be found here: https://github.com/App-vNext/Polly
|
11:598
|
More information on Docker can be found on Docker’s official website: https://docs.docker.com/
|
11:599
| |
11:600
| |
11:601
| |
11:602
|
Learn more on Discord
|
11:603
|
To join the Discord community for this book – where you can share feedback, ask questions to the authors, and learn about new releases – follow the QR code below:
|
11:604
|
https://packt.link/SoftwareArchitectureCSharp12Dotnet8
|
11:605
| |
11:606
| |
11:607
| |
12:1
|
Choosing Your Data Storage in the Cloud
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.