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


One comment

  1. Thanks for this article!
    Good to be reminded that you need to put ServiceBus related code into .NET Standard library project and can still consume that library from an ASP.NET Core application.

Leave a Reply