Azure ServiceBus in .NET Core 2.0


How to use Azure Service Bus in .NET Core.


Create a class library and add NuGet package: Microsoft.Azure.ServiceBus

Add a class to encapsulate settings:

Add a class to wrap functionality of sending messages to queue:

Add a class to wrap functionality of receiving messages from the queue:

Now you can use these wrapper classes to send message:

And receive messages:

NOTE: the sample code also include wrappers for topics and subscriptions.


The sample code will require you to setup Azure account and Service Bus. Instructions for these could be found at:

Source Code


Leave a Reply