Search code examples
blazorazureservicebusblazor-webassembly

How to use azure service bus message receive on blazor wasm on .net 7.0


I am very new to blazor wasm I want to know how to use azure service bus message receive event on blazor wasm on .net 7.0. When used a code snippet from the following link I am getting error saying platform not supported on this exception

Link- https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-dotnet-get-started-with-queues?tabs=connection-string#:~:text=The%20completed%20Program%20class%20should%20match%20the%20following%20code%3A


Solution

  • My recommendation would be don't.

    Web Assembly is a client-side technology. This means it runs in the browser, your code and configuration files are downloaded to the end-user browser. For the code it's not a big deal but the connection string (in case that's how you connect to the ASB namespace) or AAD identification information should be kept private and not endangered by being exposed on the client side.

    An alternative approach would be sending an authenticated request to an API (back-end), which packages the data as a message and sends to ASB.

    PS: if you really insist, changing transport type from AMQP to WebSockets will enable sending, but consider what I wrote above prior to doing so.