gRPC & ASP.NET Core 3.1: partie 2
Senior software developer @ Equisoft
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
Anthony Giretti
Introduction
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
2- Comment fonctionne gRPC ?
3- gRPC-web
4- gRPC & Azure
1- Retour sur l’introduction de gRPC dotnet
6- Démo
5- gRPC & Xamarin
Retour sur l’intro de gRPC dotnet
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• Framework RPC développé et open source par Google
• Compatible uniquement avec HTTP2
• Protocol Buffers (serialization en binaire)
• Non compatible avec les navigateurs
• Non supporté par Azure App Services
Comment fonctionne gRPC ?
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• POST uniquement
• Content-Type “application/grpc”
• Headers classiques
• Headers spécifiques “Trailers” (custom metadata)
• HTTP status 200 et grpc-status (1-16)
• Réponse binaire
https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md
Comment fonctionne gRPC ?
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
Code Number
OK 0
CANCELLED 1
UNKNOWN 2
INVALID_ARGUMENT 3
DEADLINE_EXCEEDED 4
NOT_FOUND 5
ALREADY_EXISTS 6
PERMISSION_DENIED 7
RESOURCE_EXHAUSTED 8
Code Number
FAILED_PRECONDITION 9
ABORTED 10
OUT_OF_RANGE 11
UNIMPLEMENTED 12
INTERNAL 13
UNAVAILABLE 14
DATA_LOSS 15
UNAUTHENTICATED 16
grpc-status
Comment fonctionne gRPC ?
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• grpc-status permet d’introduire la résilience avec Polly
Comment fonctionne gRPC ?
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• CRUD
Comment fonctionne gRPC ?
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• Validation native non supportée
• Alternative server side avec le package https://www.nuget.org/packages/Calzolari.Grpc.AspNetCore.Validation/
• Client side avec le package https://www.nuget.org/packages/Calzolari.Grpc.Net.Client.Validation/
https://github.com/AnthonyGiretti/grpc-aspnetcore-validator
Comment fonctionne gRPC ?
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• Authentification
• HTTP 401 !!!!  pas de grpc-status
Comment fonctionne gRPC ?
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• L’audit grâce aux intercepteurs
Comment fonctionne gRPC ?
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• Gestion des erreurs globales non supportées
Comment fonctionne gRPC ?
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• Healthchecks
• Versionning
• Tests d’intégrations
• Monitoring avec Application Insights (mais pas efficace)
gRPC-web
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• Compatibilité avec les navigateurs web et clients lourds
• Compatible avec HTTP1.1 & HTTP2
• Content-Type “application/grpc-web” ou “application/grpc-web-text”
• Librairie Client gRPC-web et serveur
• Activer CORS
gRPC-web
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• Plus besoin de proxy
gRPC-web
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• Configuration serveur
gRPC-web
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• Configuration client
• Générer le client à partir du fichier proto
gRPC & Azure
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• Azure App Service supporte gRPC-web
gRPC & Azure
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• Issues avec Linux App services
gRPC & Xamarin
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• Xamarin supporte gRPC-web (application déployée)
• Toujours le même problème en local
Conclusion
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• gRPC
• Serveur a serveur
• Non compatible Azure App Service
• Transport binaire
• HTTP2
• gRPC-web
• Serveur a serveur ou serveur a browser
• Compatible avec Azure App Service
• Transport texte ou base 64
• HTTP2 & HTTP1.1
Ressources
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti
• https://grpcweb.azurewebsites.net/
• https://github.com/improbable-eng/grpc-web
• https://github.com/AnthonyGiretti/angular8-grpc-aspnetcore3-1-demo
• https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md
• https://devblogs.microsoft.com/aspnet/grpc-web-experiment/
(mini) Démo
http://anthonygiretti.com/
https://twitter.com/anthonygiretti
https://www.linkedin.com/in/anthony-g-98670426/
https://github.com/AnthonyGiretti
https://www.nuget.org/profiles/AnthonyGiretti

Grpc and asp.net partie 2