Previous Azure-Service-Bus Azure-Cognitive-Services Next

Azure Service Fabric

Azure Service Fabric

Azure Service Fabric is a distributed systems platform for building and managing scalable, reliable, and easily managed microservices and containers. While it is available as a service on Azure, it can also be run on-premises or on other clouds, offering flexibility in deployment. Service Fabric powers many core Microsoft services, including Azure Cosmos DB, Azure SQL Database, and Event Hubs.

Core Capabilities

  • Microservice support: Supports both stateless and stateful microservices. Stateful services keep their data with the service itself, enabling low-latency workloads like gaming, trading, and real-time processing.
  • Orchestration: Deploys and manages containers (Docker and Windows Server) and executables across a cluster of machines.
  • High availability and reliability: Automatically handles scaling, rolling upgrades, and self-healing from faults.
  • Application lifecycle management: Provides tools for development, deployment, upgrades, and maintenance.
  • "Run anywhere" deployment: Offers consistent programming models across Azure, on-premises, and other clouds.
  • Developer productivity: Provides APIs like Reliable Services and Reliable Actors, supporting .NET and Java, with integration in Visual Studio and Eclipse.

Service Fabric vs. Other Azure Services

Comparison Azure Service Fabric Azure Kubernetes Service (AKS) Azure Service Bus
Primary purpose A distributed systems platform for building, deploying, and managing microservices and containers. A managed Kubernetes offering for orchestrating containerized applications. An enterprise message broker for decoupling applications and managing asynchronous communication.
Workload type Runs processes, containers, and executables; optimized for both stateful and stateless services. Designed for orchestrating and managing containers using Kubernetes API. Handles message queues and publish-subscribe topics; does not host applications directly.
State management Excellent support for stateful services with Reliable Collections and Reliable Actors. Uses external storage like Azure Disk or Azure Files for persistence; not natively stateful. Stores messages reliably but not general-purpose application state.
Best for Mission-critical, low-latency apps like IoT, gaming, and high-performance computing. Standard, portable, containerized applications across multi-cloud environments. Reliable, asynchronous communication between decoupled services.

What is Azure Service Fabric

Azure Service Fabric is a distributed systems platform that simplifies the packaging, deployment, and management of scalable and reliable microservices and containers. It is widely used for building cloud-native applications and running mission-critical workloads with high availability.

Key Features

  • Supports microservices (stateful and stateless).
  • Runs containers alongside microservices.
  • Automatic scaling and rolling upgrades.
  • High availability and fault tolerance.
  • Supports .NET, Java, and other runtimes.

Example: Simple Stateless Service in C#

using System;
using System.Fabric;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ServiceFabric.Services.Runtime;

namespace HelloServiceFabric
{
    internal sealed class HelloService : StatelessService
    {
        public HelloService(StatelessServiceContext context) : base(context) { }

        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            long counter = 0;

            while (!cancellationToken.IsCancellationRequested)
            {
                counter++;
                ServiceEventSource.Current.ServiceMessage(this.Context, 
                    "Hello Service Fabric! Count: {0}", counter);

                await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
            }
        }
    }
}

How It Works

  • Cluster: Service Fabric runs across a cluster of machines (nodes).
  • Application: Your application is deployed as a collection of services.
  • Stateless Service: In this example, the service just logs a message repeatedly.
  • Orchestration: Service Fabric manages deployment, failover, and scaling automatically.

Use Cases: Microservices applications, containerized workloads, low-latency systems, and enterprise-scale cloud apps.

Back to Index
Previous Azure-Service-Bus Azure-Cognitive-Services Next
*