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

how do I set the dapr appid thru code/options? could you all add some examples for options? #24

Closed aktxyz closed 2 years ago

aktxyz commented 3 years ago

Ask your question here

badgeratu commented 3 years ago

There's a couple of ways to do this, the simplest is to set it specifically in appsettings.json:

{
  "DaprSidekick": {
    "Sidecar": {
      "AppId": "MyApplication"
    }
  }
}

Anything in the DaprSidecarOptions can be put in the Sidecar section above.

Or you can do it in code via the AppDaprSidekick() extension method:

// Add Dapr Sidekick
services.AddDaprSidekick(Configuration, configure =>
{
    configure.Sidecar ??= new Man.Dapr.Sidekick.DaprSidecarOptions();
    configure.Sidecar.AppId = "MyApplication";
});

Or you can use the regular IPostConfigureOptions<T> pattern to register a post-configure handler into which you can inject anything to help you override the options at runtime.

aktxyz commented 2 years ago

thanks ! could of sworn I had tried the appsettings.json version, must have had something whacked