man-group / dapr-sidekick-dotnet

Dapr Sidekick for .NET - a lightweight lifetime management component for Dapr
Apache License 2.0
175 stars 21 forks source link

Support for ASP.NET (Framework 4.6.x and more) && pub sub #42

Open GFlisch opened 2 years ago

GFlisch commented 2 years ago

In my company we want to move to Dapr.io but like you we have a lot of .NET 4.6 ASP.NET services.

The example I have seen in your repo is based on a console application and I would like to know if it is supported to run dapr sidekick with a ASP.NET Web Application (.NET Framework) running on IIS?

The next question is also if with your library we can publish to a pub-sub component? This is what I need to integrate the new code with the old one (by using CloudEvents)? I have forked the current Dapr Client SDK to support .Net Standard 2.0 and 2.1 so we can use it also in legacy app but they have refused this.

Thanks for the support and the good job you did.

anmalkov commented 2 years ago

@badgeratu I would really appreciate if you can make it clear. Is it possible to use Sidekick with ASP.NET 4.8? Thank you in advance.

badgeratu commented 2 years ago

Hi both. TBH I've never used ASP.NET classic so I can't really say how you'd get Sidekick working with it. I can confirm it does work fine with ASP.NET Core 2.2 on .NET Framework 4.8. What would be great is if someone with ASP.NET experience ;) could have a go at getting it working, perhaps even contributing a Man.Dapr.Sidekick.AspNet integration library to help others in the same boat. I would expect it to work fine in general as long as ASP.NET can manage the lifetime of Sidekick and start/stop it along with the app. There's a couple of ways you could approach this: 1) The .NET Framework Wcf sample demonstrates the use of the DaprSidekickBuilder to create an instance of Sidekick along with a simple Console logger sink. You could try using that first. 2) Alternatively if ASP.NET has a dependency injection framework you could take a look at how we dependency inject Sidekick into ASP.NET Core which should give some guidance on a possible approach

As for supporting pub/sub I don't think that's possible on .NET Framework, all the components required to do that are in the official Dapr .NET SDK which requires a NETCOREAPP based runtime.

GFlisch commented 2 years ago

Hi Badgeratu,

I have a project using Man.Dapr.Sidekick.AspNet working with an ASP.NET classic. I will do a pull request with the example.

Now that the latest gRPC version of .NET is compatible with .netstandard 2.0 I have proposed a PR to the official Dapr .NET SDK but they have refused it. They don't want to support this. But I am thinking to build a minimal .NET SDK for .nestandard 2.0 able to connect daprd via gRPC by using the proto files in the dapr .NET SDK.

I need this for the company where I am working because I want to give the opportunity to migrate smoothly out current .NET 4.6.2+ applications and communicate with pubsub. The other possibilities don't interest me. I don't know yet if I can propose this in a specific package in my repo or add this to your...