Giter VIP home page Giter VIP logo

practical-microservices-with-dapr-and-.net's Introduction

Practical Microservices with Dapr and .NET

Practical Microservices with Dapr and .NET

This is the code repository for Practical Microservices with Dapr and .NET, published by Packt.

A developer's guide to build cloud native applications using the Dapr event-driven runtime

What is this book about?

Over the last decade, there has been a huge shift from heavily coded monolithic applications to finer, self-contained microservices. Dapr is a new, open source project by Microsoft that provides proven techniques and best practices for developing modern applications. It offers platform-agnostic features for running your applications on public cloud, on-premises, and even on edge devices.

  • This book covers the following exciting features:
  • Use Dapr to create services, invoking them directly and via pub/sub
  • Discover best practices for working with microservice architectures
  • Leverage the actor model to orchestrate data and behavior
  • Use Azure Kubernetes Service to deploy a sample application
  • Monitor Dapr applications using Zipkin, Prometheus, and Grafana
  • Scale and load test Dapr applications on Kubernetes

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Errata

  • page 182: The file path in the sentence "The corresponding ingress for order-service, which is available in the Deploy\ ingress-order.yaml file, is as follows:" must be read as "The corresponding ingress for order-service, which is available in the ``Deploy
    ingress-nginx.yaml``` file, is as follows:"
  • page 182: The command after the sentence "To apply these configurations to our Kubernetes environment, we must use the following command:" must be read as
    kubectl apply -f .\Deploy\ingress-nginx.yaml
    

Instructions and Navigations

All of the code is organized into folders. For example, Chapter02.

The code will look like the following:

"compounds":
[
  {
    "name": "webApi + webApi2 w/Dapr",
    "configurations": [".NET Launch w/Dapr (webapi)",
    ".NET Core Launch w/Dapr (webapi2)"]
  }
]

Following is what you need for this book: This book is for developers looking to explore microservices architectures and implement them in Dapr applications using examples on Microsoft .NET Core. Whether you are new to microservices or have knowledge of this architectural approach and want to get hands-on experience in using Dapr, you’ll find this book useful. Familiarity with .NET Core will help you to understand the C# samples and code snippets used in the book.

With the following software and hardware list you can run all code files present in the book (Chapter 1-10).

Software and Hardware List

Chapter Software required OS required
1-10 Docker Engine – the latest version Windows, Mac OS X, and Linux (Any)
1-10 .NET 5 Windows, Mac OS X, and Linux (Any)
1-10 Dapr, version 1 or later Windows, Mac OS X, and Linux (Any)
1-10 VS Code – the latest version Windows, Mac OS X, and Linux (Any)
10 Python 3.8 Windows, Mac OS X, and Linux (Any)
1-10 The Azure CLI – 2.15.1 or later Windows, Mac OS X, and Linux (Any)
10 Locust 1.3.1 or later Windows, Mac OS X, and Linux (Any)

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Related products

Get to Know the Author

Davide Bedin is a cloud-native architecture enthusiast, with strong and relevant experience with cloud platforms. As CTO of an ISV, Davide led its significant transformational process with the objective of creating new solutions based on the Microsoft Azure cloud. Davide particularly focused on the evolution of distributed computing to service-oriented architectures, and ultimately microservices, spending most of his developer career creating web services. As a cloud solution architect at Microsoft, Davide is responsible for the guidance and support of enterprise customers in embracing the cloud paradigm, a key enabler of their digital transformation; lately, he also plays with Dapr.

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781800568372

practical-microservices-with-dapr-and-.net's People

Contributors

dabedin avatar packt-itservice avatar packt-pradeeps avatar packtdwaynef avatar packtutkarshr avatar stormmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

practical-microservices-with-dapr-and-.net's Issues

Exception has occurred: CLR/System.Exception

I got this error while trying to run chapter03 sample :

An unhandled exception of type 'System.Exception' occurred in System.Private.CoreLib.dll: 'Could not resolve a service of type 'System.Text.Json.JsonSerializerOptions' for the parameter 'serializerOptions' of method 'Configure' on type 'sample.microservice.reservation.Startup'.'
 Inner exceptions found, see $exception in variables window for more details.
 Innermost exception 	 System.InvalidOperationException : No service for type 'System.Text.Json.JsonSerializerOptions' has been registered.
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)

app channel is not initialized

I got this error while trying to run chapter03 grpc sample :
Dapr.Client.InvocationException: Exception while invoking reserve on appId:reservation-service
---> Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="app channel is not initialized")
at Dapr.Client.DaprClientGrpc.MakeInvokeRequestAsyncWithResponse[TRequest,TResponse](InvocationRequest1 request, Boolean useRaw, CancellationToken cancellationToken) --- End of inner exception stack trace --- at Dapr.Client.DaprClientGrpc.MakeInvokeRequestAsyncWithResponse[TRequest,TResponse](InvocationRequest1 request, Boolean useRaw, CancellationToken cancellationToken)
at Dapr.Client.DaprClientGrpc.InvokeMethodAsync[TRequest,TResponse](String appId, String methodName, TRequest data, HTTPExtension httpExtension, CancellationToken cancellationToken)
at sample.microservice.order.Controllers.OrderController.SubmitOrder(Order order, DaprClient daprClient) in C:\chsarp\dapr-samples\chapter03\chapter03\sample.microservice.order\Controllers\OrderController.cs:line 36
at lambda_method(Closure , Object )
at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

HEADERS

Cache-Control: no-cache
Connection: keep-alive
Content-Type: application/json
Accept: /
Accept-Encoding: gzip, deflate, br
Cookie: ASP.NET_SessionId=aihc3wnuy0pub10ujqlklsy1
Host: 127.0.0.1:5001
User-Agent: PostmanRuntime/7.26.8
traceparent: 00-d09c700d1e38a425454a18dc08ac53b7-14f70be2d4a6bfb1-01
Content-Length: 214
Postman-Token: 67f1d1b8-4319-4b66-96af-aa6680c220f8

grpc reservation-service error: Google.Protobuf.InvalidProtocolBufferException: Full type name for Item is Item;

Hi I've been trying to make the reservation-service work with grpc as you show in your book, but I'm getting the follow error

Google.Protobuf.InvalidProtocolBufferException: Full type name for Item is Item;

I've been struggling with as the book code was relying I think in an old version of dapr and the Extension don't exists anymore, so after figuring out using the sample provided in this repository I'm getting this error.

I've seen some threads at the dapr GitHub saying that it should be something related to the way its been calling in the client app, that should be referred as grpc, but that goes very different that was showing in the book.

So any tips on that ?

invoking reservation-service in debug mode does not seem to work

If I start order-service and reservation-service manually via the commandline it works fine. I can POST an order and the reservation-service gets invoked.

However, if I start the order-service and reservation-service in VSCode via the debug launch configuration I notice that:

  • the services do not show up in the dapr dashboard
  • the services do not show up in the output of "dapr list"
  • a POST to the order-service works, but when it tries to invoke the reservation-service I always get the following exception:

Exception thrown: 'Dapr.Client.InvocationException' in System.Private.CoreLib.dll: 'An exception occurred while invoking method: 'reserve' on app-id: 'reservation-service''
Inner exceptions found, see $exception in variables window for more details.
Innermost exception System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it.

  • a POST straight to the reservation-service does work as expected

It seems that the services cannot invoke others when running in daprd? Is this a known issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.