Service Fabric is the foundational technology introduced by Microsoft Azure to empower the large-scale Azure service.
In this session, you’ll get an overview of containers like Docker after an overview of Service Fabric, explain the difference between it and Kubernetes as a new way To Orchestrate Microservices. You’ll learn how to develop a Microservices application and how to deploy those services to Service Fabric clusters and the new serverless Service Fabric Mesh service. We’ll dive into the platform and programming model advantages including stateful services and actors for low-latency data processing and more.
You will learn:
1. Overview of containers
2. Overview of Service Fabric
3. Difference between Kubernetes and Service Fabric
4. Setup Environment to start developing an application using Microservices with Service Fabric
Conference Website: https://globaltechconferences.com/event/women-data-summit-2021/
C# Corner - Community of Software and Data Developers: https://www.c-sharpcorner.com
Show More Show Less View Video Transcript
0:00
Hello. So I will present today a session about service fabric and microservices
0:07
What you will learn today, you will learn today the basics of service fabric, local deployment, and remotely in the clouds
0:15
As mentioned before, so I am Microsoft MVP in developer technologies. I am software architect, member and speaker in .NET Foundation
0:26
Foundation. I'm also MCT and Azure certified. You can follow me on Medium
0:33
blog, LinkedIn, YouTube or Twitter. You can find all links here and if you have
0:38
any questions during the presentation you can use the chat option and I will
0:44
answer you in the end of the session. We will talk at the beginning about the
0:50
advantages of microservices compared to monolithic applications, then an and environment preparation in order to start the service fabric demo
1:01
In a changing market, one of the main challenges of maintaining the competitiveness of digital businesses remains IT agility
1:12
However, in their current state, computer systems are struggling to adapt to the latest technological developments
1:20
such as mobility or Internet of Things, and to their new requirements
1:27
With a large number of dependencies of services linked to the lifecycle of an IT project
1:35
each modification of the source code of a basic monolithic application can destabilize it in maintenance
1:42
For this reason, companies have resorted to more optimized, scalable architecture ensuring continuous availability and less costly in terms of research conception and in particular oriented microservices
1:59
This change is essential facing the aggressive competition and in particular that of startups which are not yet congested by rigid infrastructure
2:12
Before talking about microservices, we need to understand the difference between the traditional application approach and the microservices application approach
2:22
Any application is built as a collection of services, can be developed, tested, versioned, deployed, and scaled
2:31
For monolithic applications, scales is done by cloning the app on multiple server or virtual machines
2:38
But for microservices, care is done by deploying each independently with multiple instances across server or across virtual machines
2:49
I highly recommend seeing more detail in this link here on Martin folder sites
2:56
Microservices are very similar to beehives, with a hive thousands of peas coexist and help
3:10
each other for a single coming goal, the survivor of the colony
3:16
The queen, the workers and the drones, each one have their particularities and must therefore
3:23
assume very distant task. When developing a server-side application, you can start with a modular, hexagonal or layered architecture, which consists of different types of components or layers
3:40
In our example here, we start by the presentation layer, its UI user interface layer
3:47
This can be a web or mobile or desktop application. The services layer is responsible for handling HTTP requests and responding with either HTML or JSON or XML
4:03
Specific for web services APIs. The business logics is the application's business logic
4:11
It is a note of our application. And finally, the database access layer is the data access object responsible for access
4:22
to the database. Despite having a logically modular architecture, the application is packaged and deployed as
4:30
a monolith. Monolithic applications are more of a single, complete package, having all the related needed
4:38
components and services encapsulated in one package. But for microservices, the idea is really simple
4:45
It consists to split your application into a set of smaller interconnected services instead
4:51
of building a single monolith application. Each microservices is a small application that has its own hexagonal architecture consisting
5:00
of business logic along with various adapters. Some microservices would expose REST, RPC, for example, or message-based API, and most
5:11
Most service consume APIs provided by other services. Other microservices might implement a web user interface
5:21
Microservices are deployed independently with their own database per service, as we can see in the second approach here
5:34
Microservices allow us to scale, deploy, deploy parts of the application independently
5:40
They offer great distributed software challenges. But with these benefits, we cannot always choose microservices
5:48
because they are intended for large scalable and long-term distributed applications. Do not underestimate the complexity
5:57
in implementation, testing, and in maintenance. We will now present the difference, architecture
6:06
and patterns of microservices. This table summarizes the modern patterns and technologies to be used by containers
6:16
There are many models. Most of them are linked or come from domain-driven design
6:24
And here we can find the service fabric. It's our subject today
6:33
Companies face challenges in their passage to the cloud because, for example
6:38
there is the optimization of the development of microservices to be taken into account
6:44
Similarly, achieving readable consistency of state and data without latency problems, monitoring and governance at global and granular levels. Execution of highly secure applications
6:58
on large scale, until integration and continuous developments. Microsoft Azure includes quite a few past services to host and deploy microservices
7:17
We have here some examples. We can deploy our microservices as app service as a service fabric or as a Kubernetes service or as a container instance and we can use batches There is three major services in Azure here
7:38
There is service fabric, which we will see in more detail during our session today
7:43
It supports microservices developed by any language, and service fabric mesh has been retired from here
7:52
We also have Azure Kubernetes, which is a container orchestrator containing microservices easy to manage
8:01
And finally, we have Azure Function, which is a part of the services will act according to the triggers
8:11
So we have three. So what's Service Fabric? Service Fabric allows you to create and manage scalable and realable applications
8:22
composed of microservices. These distributed microservices run at very high density on a shared
8:29
pool of virtual machines which correspond to a cluster. Service Fabric represents the next
8:37
generation platform for building and managing these cloud level tier one enterprise application
8:44
running in containers and works with other providers such as AWS and OpenStack
8:56
We will see how we create a local Service Fabric cluster using SDK server
9:03
This cluster will allow us to create Service Fabric application using Visual Studio and
9:09
and deployed locally after, we will deploy it on Service Fabric Cluster
9:14
in Microsoft Azure. So Service Fabric Cluster is a network connected set
9:22
of machine, virtual machine, into which your microservices are deployed and managed
9:29
What is cluster? Cluster is a set of nodes that are virtual machines
9:35
Node numbers depend from the use of clusters. In the development phase, one node is used
9:43
but in production, you need to have more than five. Every node has an operating system
9:50
It can be Windows or Linux with runtime. A node can host multiple applications
9:57
It depends from the research available in the virtual machine. Service Fabric can be run anywhere. You can create clusters for Service Fabric in many environments, including Azure or local, on Windows Server or on Linux. You can even create clusters on other public clouds
10:24
In addition, the development environment in the SDK is identical to the production environment
10:34
with no emulator involvement. In other words, what runs on your local deployment cluster is deployed to the clusters in other
10:43
environments like production environments. So Azure Service Fabric is an open source project and is used in many services in Azure infrastructure
10:56
as well as other Microsoft services including Azure Event Hub, Azure Cosmos DB, Azure SQL
11:04
Server Dynamics 365, Cortana, the major subsection of Service Fabric can be seen below here
11:15
As you can see, here is related to Microsoft services and here related to Azure and Azure DevOps, for example
11:28
Service Fabric is a platform that makes EASIA to build and deploy microservices-based application
11:35
handling both stateful and stateless operation. It will run on any Windows system
11:42
and there is also a Linux version, which means that it is portable across multiple cloud environments
11:49
including any provider, like On Mistake, VMware, Amazon Web Services. Apps that are created in the Azure Service Fabric environment
12:00
are made up of granular microservices, small chunks of code which are uploaded and run separately
12:08
These microservices communicate with each other using services application programming interface. We talk about APIs here
12:18
Because microservices are modular, it's possible to scale each component of an app separately
12:24
which simplifies the process of rolling out chains in contrast to traditional monolithic architecture
12:33
Service fabric provides lifecycle management capability to microservices-based application, and the microservices are hosted inside containers
12:41
that are deployed across the service fabric clusters. Using container instead of virtual machines means a massive increase in density and greater
12:51
still density can be achieved by moving from container to microservices in this container
12:59
So here we have the service fabric architecture. We just mentioned the first one, the second one
13:05
So the first one is the first layer from the bottom here
13:10
Transport subsystem is responsible for providing secure communication channels between nodes in a service fabric cluster
13:18
The federation subsystem above, it helps logically group physical or virtual nodes into a cluster so that can be managed as a unit
13:29
This helps service fabric with tasks such as failure detection, leader detection, and routing
13:35
Readability of the workload hosted on Service Fabric is managed by the readability subsystem
13:43
It owns the responsibility of replication, research management, and failover. The hosting and activation subsystem manages the lifecycle of the workload on every node
13:56
and the management subsystem is responsible for managing the lifecycle of your application
14:01
The testability subsystem helps developers test their workload before and after deployments
14:12
If you need to have more details about the other subsystems, you can consult the official
14:21
documentation of Microsoft. Now we'll go to see an overview about monitoring and diagnostics
14:31
Monitoring and diagnostics are critical to development testing and deploying workload in any cloud environment
14:41
For example, you can track how your applications are used, the actions taken by the Service
14:46
Fabric platform, your resource utilization with performance counters, and the overall health of your cluster You can use this information to diagnose and correct issues and prevent them from occurring in the future The next few sections will briefly explain
15:06
each area of Service Fabric Monitoring to consider for production workloads. Here we can see we have two tools
15:14
that we will present today. We will use today Service Fabric Explorer during our demos
15:21
And we can use Azure Monitor if you have more details. phase about monitoring and diagnostics
15:31
Before we begin, we must meet these prerequisites in order to be able to configure our Windows development
15:38
environment to create Service Fabric. As you can see here, we need Windows 10
15:45
It should be a professional enterprise version to be able to install Docker installation
15:51
because we will talk today about containerizing our application as a service fabric
15:59
We can use Visual Studio 2019 or 2017 as building support for Docker
16:06
You can use the new version of Visual Studio that is in preview mode 2022
16:15
We will use .NET Core SDK. SDK of Microsoft Service Fabric, I will leave the link after
16:23
And we need Docker for Windows. It's optional if you want to try containerizing
16:29
And Docker tools. Now we will set up our Windows development environment
16:37
to build Service Fabric. To do that, I recorded a video that will help us to go faster
16:46
and to do more than one demo. So I will start the video here
16:52
So we will start by installing Visual Studio. I will show you the link where we can download the 2019 version
17:03
and the last one that is in preview mode, we can use it to do this demo too
17:10
So we have many version here for Macintosh or Windows. We will install the Microsoft Azure Service Fabric here
17:18
You will find the link. So you will get web platform installer here that will be loaded
17:25
You will select Microsoft Azure Service Fabric. You will install. Click on install
17:33
It's in French, but you accept or not here. And the installation can take a few minutes
17:42
But here it's recorded. So I tried to zip all on the time
17:49
and you will get this information. Click on finish. It's in French. And after we will, our SDK is installed
18:00
You can use, if you have old version, you can use these things to install only SDK installation
18:08
Here we check in Visual Studio if we have already the template of Service Fabric
18:17
So here, we click on create a new project. We will try to check fabric here
18:29
to see if we have our template already added on us. As you can see here, service fabric application
18:37
The template is added. Now we set up a local service fabric cluster
18:47
To do that here, we will try to search for Service Fabric, as you can see here
19:02
And you executed as an administrator. You will have this icon. So you need to start our local cluster
19:15
We need to wait a few times to be launched. So we will set up before the local cluster
19:22
We will start it after. And after, we will choose Manage local cluster
19:27
to open Service Fabric Explorer. Here we will choose one node or five
19:36
As I said, for development, you need only one. For production, you need more than five
19:45
After, we will start our local cluster
19:56
And we will use Manage Local Cluster and we will get Service Fabric Explorer here, as
20:03
you can see. We have one node. I select one node, we have only one node here
20:14
And here we will have our application, no application, no services, no replica
20:21
Now we'll create a service fabric using Visual Studio
21:01
to select. We start by a simple service, stateless service. We don't need today to do a stateful
21:13
We only test stateless service. So I'll give a name here, stateless service
21:18
demo, for example. And we click on create. We can have more
21:27
services that you can use it in .NET Framework Core or .NET Standard
21:35
the old version, we can create server-stateless service. And here we have our application
21:43
As you can see, we have here, the application manifest is the configuration file
21:50
of our parts, our application. As you can see, we have two projects
21:57
The first one, when we have the icon of Service Fabric, the second one is the service
22:05
Here we just have service, the stateless service. This is our class that inherits from stateless service
22:21
I click on Start to run my application. Thank you And here we see the diagnostics events as you can see here
22:43
And we need to restart under different credentials. We need to run our Visual Studio as administrator
22:55
Here we have the event name and this message, my application, my service, stateless service is running now
23:05
And we will check on service fabric, explorer, if the application run or not
23:14
Here as you can see we have an error maybe because the service is not run
23:23
Now it's okay. So all service is running well without any error
23:29
But if you have any error we can check here the error. If you have a warning too
23:33
So here it's okay. We don't have any problem. Now we will publish our Service Fabric in Visual Studio, using Visual Studio
23:48
We open Visual Studio and we choose publish here
23:59
Select publish here. Here we have three profiles, one for local, one node, another for five nodes, and for
24:08
local cluster we select local. we will select OneNote because we selected before OneNote in our
24:16
configuration and we click on publish and my application will be published
24:22
always as a service fabric but it will be locally published locally in the
24:31
note that is defined locally It can take a few seconds, let's say
24:42
And we will check that here. As you can see here, Service Fabric
24:49
My application is running now. Here we have all information related to the application
24:56
So it's really easy to use Service Fabric Explorer to check the health of our application
25:02
or if you have any errors, so it's easy to check which error we have
25:08
Now we will build .NET Service Fabric application. To do that, we will use an existing application in Microsoft documentation
25:20
related to Service Fabric here in Azure samples, as you can see. And we will try to run it in our cluster as Service Fabric
25:32
You can fork this link as I will do now in my GitHub account to be able to use it
25:47
Now we'll open this application using Visual Studio. So I will close this one
25:59
And we will clone the repository. I will add this one, this link
26:09
Select the path where it will be physically in my machine. Add it, clone it
26:19
We will check our application now. As you can see here, we have always projects that include our configuration related to our
26:36
nodes, and we have data voting here, simple projects that will include our data, and web
26:48
application, its MVC application. We will start the application after. So you can see here it's NBC
26:56
We have views, we have an index, we have controllers. It's voting application
27:04
So I will see our voting application locally. We'll launch it locally to see
27:18
Here, it's really simple. We will add a vote, for example, add one, another vote
27:24
We can remove the vote. So it's really simple. But we have two projects here, the first one, the data
27:31
and the second one is this web application. And we started our application here
27:37
As you can see, we started. We have two. We have the previous one, that is the service
27:43
And we have the second one that we already launched related to the voting
27:48
In OneNote. Now we will deploy a Service Fabric application to a cluster in Azure
27:55
Here we will publish, click on publish. This time we will use the cloud because we will publish it to Azure Service Fabric
28:12
We click create a new node. We will select a number of nodes
28:20
I will add five or three. So it depends from you. We need to add a new research group, for example, here
28:29
We need to add all information related to your certification here, passwords
28:35
So we need to fill all information in every part here. We need to identify the certification output, I will do this one
28:53
We have information related to your VM that will include your cluster, username, password
29:03
We need to select the virtual machine image, it can be Windows or Linux
29:12
Here I will add the port. It's OK for that. 80. Oh, here is 8080 to be able to see our application
29:26
We missed it in the beginning. Something here. We click on Create to see what we missed it
29:32
Because we need to fill our information here. So here we can say you are missing something here
29:38
As you can see, we need to select the location. And here we can find our virtual machine size
29:45
You select the size that is suitable to your application. So here we click on Create
29:54
You still have missing information here. We need to give a name, vote in cluster
29:59
for example, because the other one exists already. I'm going to create after we choose, okay
30:08
The publishing of this application can takes few minutes to be able to see that after when you check it
30:15
on Azure portal. So we need to wait a few minutes, but here it's okay to get this screen
30:24
Now we will check it on Azure portal. We will select the voting research group here
30:36
As you can see, we have many things here. So this line succeeded
30:42
We have here the voting cluster. We will go to the search
30:48
It can take time. But here we have many research audits, as you can see here
30:54
And we will find our voting cluster. All the other research are related to the cluster
31:00
So we have the VM, we have many, a complete infrastructure added
31:05
Now I will check the Service Fabric Explorer here. We need to check this one because you need to certification
31:15
If you have added any certification, you can use it. So we have three nodes, no application now
31:22
Because we didn't deploy the application, we just created our cluster. So we click on publish and now we get our application
31:37
Now we check our application. This is my application here, vote one, as you can see
31:46
Vote two, vote one to vote. My application is published and we are able to see it up
31:58
Now to execute Docker container or service fabric. Docker is a tool that makes it easier to create deploy and drive application by using a containerization approach These containers are lightweight and take less time to start than traditional server These containers are also increased performance
32:20
and low cost while offering proper research management. Another benefit to use Docker is that you no longer need
32:28
to pre-locate the memory to each container. If we come back to our 5R container for container
32:37
we can see how we can deploy if we want to re-host or refactor
32:42
and the microservice approach if we decide to re-architect. And for a new application, we have to build patterns
32:49
to adopt cloud-native strategy in the future. So we have all our re-architect, re-host, refactoring
33:02
We have many strategies that we can use with containers. Now we will build an execute Docker container
33:08
in Service Fabric. Here we have Docker Enterprise that is installed in my machine
33:21
And we will check if all settings are okay. Here we will check the images
33:31
and we will try to select the image here. We have remote repositories or local if we run local containers here
33:44
Now we will try to create a new project for containers
33:55
I will show you how we can select the template. Again, we will search for a service fabric application
34:03
It's in the history of Visual Studio, so it's easy to use
34:08
Fine, now we say service fabric, container demo, framework, we click on creates
34:17
and in the button here, we have container. What we need here we need a name to give the server the service my container for example and we need the image name so we need to deploy an image locally or remotely to be able to use it here as service fabric so we not create our
34:43
application or container inside the project of service fabric we give after all information
34:50
needed to be able to access to the container. Or you can set up a machine for containers, it depends
34:58
Now we check here from my image. I mean, we can use, for example
35:04
my ASP.NET Core image if you need to test that or any existing image
35:12
So if you use ASP.NET, we don't need to add a username or password
35:18
If you use your images, you need to add all this information
35:25
Now we build it. Now here, we can try to build to see our application
35:31
And in the configuration file here, we can find the image name
35:37
As you can see here, reference here. We have here ASP.NET Core 5
35:48
And when we compile our application, we do the same to publish it as Service Fabric
35:57
It will be a container as Service Fabric. We go back to the presentation here
36:14
Today we just tested only stateless services, but in Service Fabric, we have stateless services and stateful service
36:23
So we have two main types of services that we can build with Service Fabric
36:29
Stateless services, we use it in our first demo projects and no state is maintained in the service
36:38
Longer term state is stored in an external database This is your typical application data layer approach to building services that you are already likely familiar with
36:51
Stateful services. State is stored with a service. Allows for state to be persistent without the need for an external database
37:03
data is co-located with the code that is running the services. As you can see here
37:12
We use loadmancer always. And as you can see here, the stateful services
37:19
And here are the stateless services. Today we get an overview about microservices
37:29
with the difference between monolithic and microservices. We have an introduction to Service Fabric and Architecture
37:38
We prepared our environment to do all these demos. To set up local Service Fabric cluster, to create a Service Fabric using Visual Studio
37:48
to publish Service Fabric in Visual Studio, to overview, monitoring and diagnostics, build
37:55
a .NET Service Fabric application, deploy a Service Fabric application to a cluster
38:02
in Azure to build and execute Docker container in Service Fabric. If you need more information about that, you can download here the Service Fabric SDK build application
38:16
You can have many, many samples here. Many samples again here in Azure samples
38:23
You can learn more tutorials and video here. I leave this link
38:30
We can deploy samples out for free on Azure. Try Service Fabric here, the link to deploy our Service Fabric
38:39
And you can create production cluster here. This is the link. Thank you if you have any questions
#Office Services
#Enterprise Technology
#Programming
#Engineering & Technology
#Distributed & Cloud Computing


