microservices für .net entwickler - bridgingit...
TRANSCRIPT
![Page 1: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/1.jpg)
Microservices für .Net Entwickler
![Page 2: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/2.jpg)
Tobias Meier
Lead Softwarearchitekt Microsoft
Standort Nürnberg
Königtorgraben 11
90402 Nürnberg
Standort Zug/Schweiz
Baarerstraße 14
CH-6300 Zug
Standort Mannheim
N7, 5-6
68161 Mannheim
Standort Karlsruhe
Rüppurrer Straße 4
76137 Karlsruhe
Standort Stuttgart
Marienstraße 17
70178 Stuttgart
Standort München
Riesstraße 12
80992 München
Standort Frankfurt
Solmsstraße 4
60486 Frankfurt
Standort Köln
Waidmarkt 11
50676 Köln
Wir bringen Dinge zusammen
http://blog.bridging-it.de/author/Tobias.Meier [email protected] @bitTobiasMeier
„
![Page 3: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/3.jpg)
Agenda
Status quo
Was sind Microservices
Service Fabric Cluster
Entwickeln für Service Fabric 1
Pause: Essen
Entwickeln für Service Fabric 2
![Page 4: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/4.jpg)
Viele reden von Microservices,
wer entwickelt bereits
Microservices ?
![Page 5: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/5.jpg)
![Page 6: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/6.jpg)
![Page 7: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/7.jpg)
![Page 8: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/8.jpg)
![Page 9: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/9.jpg)
![Page 10: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/10.jpg)
Monolitische Architektur
Schichten Architektur
Wächst und wächst …
Skalierung über Hardware
bzw. VMs <=> DB Locks
![Page 11: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/11.jpg)
Microservice-Architektur
Kleine, unabhängige Services
Eigener Prozess
Leichtgewichtige Kommunikation
Unabhängige, automatisierte Installation
Verschiedene Technologien und/oder Programmiersprachen möglich
Unabhängige Datenspeicherung
Minimaler zentralisierter Managementaufwand
![Page 12: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/12.jpg)
“In short the microservice architectural style [...] is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies. “
Martin Fowler, https://martinfowler.com/articles/microservices.html
![Page 13: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/13.jpg)
Microservice = SOA Done right
= SOA + DDD + Patterns
Patterns: Autonome Services, Bounded Context, Event Driven Design, Continuous Delivery, …
![Page 14: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/14.jpg)
„Ok, dann teilen wir unseren Monolithen in hunderte Services auf.“
![Page 15: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/15.jpg)
Auch verteilte Anwendungen haben Nachteile …
![Page 16: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/16.jpg)
Komplexität von verteilten Anwendungen
Gesamtanwendung hat viele Abhängigkeiten
Komplexität der Orchestrierung
Daten-Konsistenz
Höherer Entwicklungsaufwand
Kommunikation untereinander
Netzwerklatenz
Versionierung von Schnittstellen
Abwärtskompatibilität
Welche Version ist installiert ?
Testbarkeit ist schwerer
![Page 17: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/17.jpg)
The Art of Scalability: Scale Cube
http://theartofscalability.com/
X: Horizontale Skalierung
Y: F
unktionale
Skalie
rung
![Page 18: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/18.jpg)
Microservices in der Microsoft-Welt
Container Services: http://aka.ms/acs
Azure Functions: https://functions.azure.com/try
Service Fabric
![Page 19: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/19.jpg)
Aufbau Service Fabric
Microservice
WebAppOwin
Microservice
WebAppAsp.Net Core
Windows Container
Guest Executable
Reliable Actor API Reliable Service API
Service Fabric
On-Premise Azure
Windows Server LinuxWindows Server Linux
Microservice
Java
Microservice
Hosted in Container
![Page 20: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/20.jpg)
Service Fabric: Platform as a service
Microsoft nutzt Service Fabric:
Azure Core Infrastructure
Azure Sql Database
Bing Cortana
Document Db
Event Hubs
IoT-Suite
Skype for Business
![Page 21: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/21.jpg)
![Page 22: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/22.jpg)
Beispiel ModuleDemo der fertigen Anwendung
![Page 24: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/24.jpg)
Beispielanwendung
Benutzer kann sich registrieren
Thumbnails von Fotos werden angezeigt
Fotos können hochgeladen werden.
Aktuell nur Command-Line-Interface: Benutzer wählt ein Foto aus und bewertet es.. Zusätzlich können auch Kommentare geschrieben werden.
Angedacht: Wenn ein Foto im Detail aufgerufen wird, werden alle
Kommentare angezeigt. Authentification / Authorization
![Page 25: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/25.jpg)
Service Fabric
PhotoAward.Platform
StatelessWebApi und
Fileserver
PhotoAward.MemberManagement
Statefull Service
PhotoAward.PhotoManagement
Statefull Service
PhotoAward.Thumbnail
Stateless Service
PhotoAward.PhotoActor
Actor Service
PhotoAward.MemberActor
Actor Service
Me
mb
erA
ctor.
Inte
rfaces
Ph
oto
Acto
r.
Inte
rfaces
Thu
mb
naiil.
Inte
rfaces
Me
mb
erM
anagem
en
t.
Inte
rfaces
Ph
oto
Man
agem
en
t.
Inte
rfaces
Ports: 8200, 8443
Co
nso
le.C
lien
tP
ho
toA
ward
Ap
p(A
ngu
lar2)
API-Gateway
![Page 26: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/26.jpg)
Service Cluster On Azure
https://github.com/Microsoft/azure-docs/blob/master/articles/service-fabric/service-
fabric-cluster-creation-via-portal.md
Vorbereitungen
Evtl. Ressourcengruppe
erstellen
Evtl. Key Vault anlegen
Zertifikat eintragen
Durchführung
Service Fabric Wizard starten
![Page 27: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/27.jpg)
Vorbereitungen: Key Vault
LoginPS C:\> Login-AzureRmAccount
Key Vault anlegen PS C:\> New-AzureRmKeyVault -VaultName 'westeuropeVault' -
ResourceGroupName 'servicefabricdemo' -Location 'Westeurope' –EnabledForDeployment
Vault Name : westeuropevault
Resource Group Name : servicefabricdemo
Location : Westeurope
Resource ID : /subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/servicefabricdemo
/providers/Microsoft.KeyVault/vaults/westeuropevault
Vault URI : https://westeuropevault.vault.azure.net
Tenant ID : 11111111-1111-1111-1111-111111111111
![Page 28: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/28.jpg)
Vorbereitungen: Testzertifikat hinzufügen
Download Hilfsskripte: https://github.com/ChackDan/Service-Fabric/tree/master/Scripts/ServiceFabricRPHelpers
ImportPS C:\> Import-Module "C:\Projekte\Service-Fabric-
master\Scripts\ServiceFabricRPHelpers\ServiceFabricRPH
Testzertifikat erzeugenPS C:\> Invoke-AddCertToKeyVault -SubscriptionId
$SubID -ResourceGroupName "servicefabricdemo" -Location "westeurope"
-VaultName "mywesteuropevault"
-CertificateName "bitdemophotoappcertificate1"
-CreateSelfSignedCertificate
-DnsName "bitdemophotoawardapp.westeurope.cloudapp.azure.com"
-OutputPath "c:\Certificates"
![Page 29: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/29.jpg)
Vorbereitungen: Testzertifikat hinzugefügt
Name : CertificateThumbprint
Value : 885BE4B2E6F80FD32A022E5087B2EAE5311FDEB8
Name : SourceVault
Value : /subscriptions/00000000-0000-0000-0000-
000000000000/resourceGroups/servicefabricdemo/providers/Microsoft.KeyVau
lt/vaults/westeuropevault
Name : CertificateURL
Value :
https://westeuropevault.vault.azure.net:443/secrets/bitdemophotoappcertif
icate1/22223333222222221111222211112222
![Page 30: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/30.jpg)
Service Fabric Cluster anlegen (1 / 5)
![Page 31: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/31.jpg)
Service Fabric Cluster anlegen (2 / 5)
![Page 32: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/32.jpg)
Service Fabric Cluster anlegen (3 / 5)
![Page 33: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/33.jpg)
Service Fabric Cluster anlegen (4 / 5)
![Page 34: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/34.jpg)
Service Fabric Cluster anlegen (5 / 5)
![Page 35: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/35.jpg)
Stateless Service
Zustandsloser Service
Typisches Modell für heutige Webanwendungen
Daten können extern gehalten werden Sql Datenbank
DocumentDB
Azure Storage
![Page 36: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/36.jpg)
Reliable Service API
Stateless oder Statefull Service
Naming Service
Zugriff auf Service Fabric APIs
Modelle zum Data-Upgrade
Zuverlässigkeit
Reliability
Verfügbarkeit
Availability
Skalierbarkeit
Scalability
Beständigkeit
Consistency
![Page 37: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/37.jpg)
Visual Studio immer als Admin starten
![Page 38: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/38.jpg)
Beispiel ModuleHello World
Web API ProjektRNDemo
Lokales Cluster
![Page 39: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/39.jpg)
![Page 40: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/40.jpg)
Statefull Service
Zustand bleibt auch nach Neustart erhalten
Synchronisation über Replicas
StateManager
Reliable Collection
Transaktionen
![Page 41: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/41.jpg)
Beispiel ModuleStatefull Service
![Page 42: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/42.jpg)
Reliable Collectionsusing (var tx = StateManager.CreateTransaction()){
var members = await StateManager.GetOrAddAsync<IReliableDictionary<string,Person>>("members");
await members.AddOrUpdateAsync(tx, person.Email, person, (key, p) => person);
person.Email = person.Email.ToUpper();
await tx.CommitAsync();}
ToUpper() wird NICHT übernommen
![Page 43: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/43.jpg)
Reliable Collectionsusing (var tx = StateManager.CreateTransaction()){
var members = await StateManager.GetOrAddAsync<IReliableDictionary<string,Person>>("members");
person.Email = person.Email.ToUpper();
await members.AddOrUpdateAsync(tx, person.Email, person, (key, p) => person);
await tx.CommitAsync();}
ToUpper() wird übernommen
![Page 44: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/44.jpg)
Tipp: Objekte sollten Immutable sein
Private Setter
System.Collections.Immutable
https://www.nuget.org/packages/System.Collections.Immutable
![Page 45: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/45.jpg)
Immutable Collection[DataContract]public sealed class PersonData{public PersonData(string name, IEnumerable<string> emails){this.Name = name;Emails = (emails== null) ? ImmutableList<string>.Empty :emails.ToImmutableList();
}[DataMember] public readonly string Name;[DataMember] public IEnumerable<string> Emails { get; private set; }
[OnDeserialized]private void OnDeserialized(StreamingContext context){Emails = Emails.ToImmutableList();
}}
![Page 46: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/46.jpg)
Reliable Actors
![Page 47: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/47.jpg)
Actor: Lifecycle
Automatisch erzeugt
Können manuell explizit gelöscht werden
Akteuere können „schlafen gelegt“ werden
![Page 48: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/48.jpg)
Knoten 1
Reliable Actors
Partition 1
Partition 2
Partition 3
Knoten 2
Partition 1
Partition 2
Partition 3
Actor Proxy
Knoten 3
Partition 1
Partition 2
Partition 3
Client (Statefull Service, weitere Actor, …)
![Page 49: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/49.jpg)
Actor erzeugen
var data = …
var photoActorId = ActorId.CreateRandom();
var client = this._actorClientFactory.CreateClient(photoActorId);
await client.SetPhoto(data, CancellationToken.None);
await tx.CommitAsync();
![Page 50: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/50.jpg)
Actor löschen
var svc = (IActorService) this.ActorService;
await svc.DeleteActorAsync(this.Id, cancellationToken);
![Page 51: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/51.jpg)
Beispiel ModuleActor-Service
![Page 52: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/52.jpg)
Backup and Restore
Ableitung vom Actor Service
Methode BackupAsync aufrufen
https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-actors-platform
https://github.com/Microsoft/azure-docs/blob/master/articles/service-fabric/service-fabric-reliable-services-backup-restore.md
![Page 53: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/53.jpg)
Actor: Timer
Wrapper um .Net Timer
RegisterTimer
Nach Beendigung des Callbacks startet das nächste Zeitfenster
Unregister Timer
„Schlafen gelegte“ Actors erhalten keinen Timeraufruf
![Page 54: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/54.jpg)
Actor: Reminder
Reminders werden auch zu bestimmten Zeitpunkten ausgelöst
Sie werden IMMER ausgelöst
public class ToDoListActor : Actor, IPhotoAwardActor, IRemindable{
public Task ReceiveReminderAsync(string name, byte[] context, TimeSpan dueTime, TimeSpan period){
if (name("Abgabetermin")){
int amountToPay = BitConverter.ToInt32(context, 0);System.Console.WriteLine("Please pay your cell phone bill of ${0}!", amountToPay);
}return Task.FromResult(true);
}}
![Page 55: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/55.jpg)
Beispiel ModuleDemo: Statefull Actor
![Page 56: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/56.jpg)
Dependency Injection und Unit Tests
Asp WebApi kann Dependency Injection verwenden
In sonstigen Services nicht benötigt!
Mock-Klassen für StateManager, ReliableCollections,
Transaktionen u.ä. manuell schreiben
![Page 57: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/57.jpg)
Beispiel ModuleDemo: Unit Testing
![Page 58: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/58.jpg)
Update
Application Version erhöhen
Code Version erhöhen
Evtl. Data Version erhöhen
![Page 59: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/59.jpg)
Continuous Delivery
TFS 2017 und TFS Online Eigene ServiceFabric Tasks für Build
und Release:
Versionsnummer setzen
Deployment
![Page 60: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/60.jpg)
1. Endpunkt im TFS definieren
![Page 61: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/61.jpg)
2. Continous Delivery erzeugen …
![Page 62: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/62.jpg)
3. Build Template bearbeiten
![Page 63: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/63.jpg)
3. Build Template bearbeiten (Ergebnis)
![Page 64: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/64.jpg)
4. Release Template
![Page 65: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/65.jpg)
![Page 66: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/66.jpg)
Vertrag§1. Service 1 §1.1. Schnittstelle§1.2. Daten
![Page 67: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/67.jpg)
Microservices für .Net Entwickler
Service Fabric bietet leistungsfähige
Plattform mit Z-Scale
Alles hat seinen Preis
Continous Delivery von Anfang an
Clustererstellung skripten
Clusterplanung ist komplex
![Page 68: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/68.jpg)
Microservices für .Net Entwickler
Out of Scope
Authentication und Authorization
Partitionierung der Daten
Backup / Restore
Docker
…
![Page 69: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/69.jpg)
Understanding Azure –a guide vor developers
http://aka.ms/adg
Service Fabric SDK
http://aka.ms/ServiceFabricSDK
Beispiele von Microsoft
http://aka.ms/ServiceFabricSamples
Case Studies
https://blogs.msdn.microsoft.com/azureservicefabric/
tag/case-study/
Beispielanwendung
http://blog.bridging-it.de/author/Tobias.Meier
![Page 70: Microservices für .Net Entwickler - BridgingIT GmbHblog.bridging-it.de/.../2017.04-microservices_rn.pdf · 2019-08-05 · Was sind Microservices Service Fabric Cluster Entwickeln](https://reader034.vdocuments.pub/reader034/viewer/2022042310/5ed8a87b6714ca7f4768550a/html5/thumbnails/70.jpg)
Vielen Dank
Email: [email protected] Twitter: @bITTobiasMeier
Blog: http://blog.bridging-it.de/author/Tobias.Meier