You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/service-fabric/service-fabric-reliable-services-quick-start.md
+12-9Lines changed: 12 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,20 @@
1
1
---
2
2
title: Create your first Service Fabric application in C#
3
3
description: Introduction to creating a Microsoft Azure Service Fabric application with stateless and stateful services.
4
-
author: vturecek
5
-
6
4
ms.topic: conceptual
7
5
ms.date: 07/10/2019
8
-
ms.author: vturecek
6
+
ms.custom: sfrev
9
7
---
10
8
# Get started with Reliable Services
9
+
11
10
> [!div class="op_single_selector"]
12
11
> *[C# on Windows](service-fabric-reliable-services-quick-start.md)
13
12
> *[Java on Linux](service-fabric-reliable-services-quick-start-java.md)
14
-
>
15
-
>
16
13
17
14
An Azure Service Fabric application contains one or more services that run your code. This guide shows you how to create both stateless and stateful Service Fabric applications with [Reliable Services](service-fabric-reliable-services-introduction.md).
18
15
19
16
## Basic concepts
17
+
20
18
To get started with Reliable Services, you only need to understand a few basic concepts:
21
19
22
20
***Service type**: This is your service implementation. It is defined by the class you write that extends `StatelessService` and any other code or dependencies used therein, along with a name and a version number.
@@ -25,6 +23,7 @@ To get started with Reliable Services, you only need to understand a few basic c
25
23
***Service registration**: Registration brings everything together. The service type must be registered with the Service Fabric runtime in a service host to allow Service Fabric to create instances of it to run.
26
24
27
25
## Create a stateless service
26
+
28
27
A stateless service is a type of service that is currently the norm in cloud applications. It is considered stateless because the service itself does not contain data that needs to be stored reliably or made highly available. If an instance of a stateless service shuts down, all of its internal state is lost. In this type of service, state must be persisted to an external store, such as Azure Tables or a SQL database, for it to be made highly available and reliable.
29
28
30
29
Launch Visual Studio 2017 or Visual Studio 2019 as an administrator, and create a new Service Fabric application project named *HelloWorld*:
@@ -41,6 +40,7 @@ Your solution now contains two projects:
41
40
**HelloWorldStateless*. This is the service project. It contains the stateless service implementation.
42
41
43
42
## Implement the service
43
+
44
44
Open the **HelloWorldStateless.cs** file in the service project. In Service Fabric, a service can run any business logic. The service API provides two entry points for your code:
45
45
46
46
* An open-ended entry point method, called *RunAsync*, where you can begin executing any workloads, including long-running compute workloads.
@@ -65,11 +65,10 @@ In this tutorial, we will focus on the `RunAsync()` entry point method. This is
65
65
The project template includes a sample implementation of `RunAsync()` that increments a rolling count.
66
66
67
67
> [!NOTE]
68
-
> For details about how to work with a communication stack, see [Service Fabric Web API services with OWIN self-hosting](service-fabric-reliable-services-communication-webapi.md)
69
-
>
70
-
>
68
+
> For details about how to work with a communication stack, see [Service communication with ASP.NET Core](service-fabric-reliable-services-communication-aspnetcore.md)
@@ -105,6 +104,7 @@ Cancellation of your workload is a cooperative effort orchestrated by the provid
105
104
In this stateless service example, the count is stored in a local variable. But because this is a stateless service, the value that's stored exists only for the current lifecycle of its service instance. When the service moves or restarts, the value is lost.
106
105
107
106
## Create a stateful service
107
+
108
108
Service Fabric introduces a new kind of service that is stateful. A stateful service can maintain state reliably within the service itself, co-located with the code that's using it. State is made highly available by Service Fabric without the need to persist state to an external store.
109
109
110
110
To convert a counter value from stateless to highly available and persistent, even when the service moves or restarts, you need a stateful service.
0 commit comments