Radzen connection pattern to Service Bus with DI

Hi guys,

i'm just sharing this pattern, as it took a while to figure out but might come in handy for others.

in my Radzen application i want to send messages to an Azure service bus queue.

for example, i run an emailer background service which listens for messages off a service bus. this is run as a continious web job.

the pattern used to make this work consists of;

  1. the service and interface created in the Server / Services folder
  2. the server startup.custom.cs OnConfigureServices registering the interface and service as a singleton
  3. a controller in the Server / Services folder which makes use of the DI interface
  4. Radzen client page custom code to hit the controller route
  5. Radzen client page template form event to call the custom code

(settings, etc have not been included, you can sort that out)

what we learnt from establishing this connection was the controller can very easily deal with DI as it's not a generated partial class.

it was also very easy to get the client page to call the controller API as there are plenty of examples for this.

what was challenging was, we were trying to originally use the server \ controller \ project \ tableController and the OnAfterCreate event to do this.

after much frustration we found endless issues with the partial class and establishing DI here. debugging was really difficult, so after lots of hair pulling we opted for the client based approach.

again, just sharing the pattern utilised. it might help