Getting started with Azure Service Bus with .NET Core

|  Posted: June 7, 2017  |  Categories: Azure

In this post, you will learn more about Azure Service Bus with .NET Core. .NET Core is a general-purpose development platform supported by Microsoft and the .NET community on GitHub. It is a cross-platform which supports Windows, macOS and Linux, and can be used in device, cloud, and embedded/IoT scenarios. Microsoft Azure Service Bus provides a reliable information delivery service. The main purpose of this service is to make communication easier and when two or more parties want to exchange information, they need a communication facilitator.



  • .NET Core
  • An Azure subscription.
  • A Service Bus namespace
  • A Service Bus queue

Create a Service Bus Namespace and Queue in the portal

Log into the Azure portal. Click “+NEW” and choose “Enterprise Integration”. Select “Service Bus”.


In the ‘Create Namespace’ blade enter the details for creation of service bus namespace.

  1. Name: Unique namespace for Service Bus
  2. Pricing Tier: Select ‘Standard’
  3. Subscription: Select the appropriate subscription from list.
  4. Resource Group: Select ‘Use Existing’ and enter the ‘Resource group’ name.
  5. Location: Select the nearest location. Click Create.


Once the ‘Service Bus deployment successful’ notification is received, Click on ‘Service Bus namespace’ object.


Click on ‘Add Queue’. On ‘Create queue’ blade enter the queue name. Select default values and click on ‘Create’.


 Once the queue is created, it should be visible in the ‘Service Bus namespace’ blade.


Click on queue ‘Orders’. In the Setting pane for queue ‘Orders’, click on ‘Shared access policies’.


Click on ‘Add’ in ‘Shared access policies’ blade. Enter Policy name ‘write’ and select the claim ‘Send


Repeat the previous step to create policy ‘read’ with claim ‘Listen’.


Both policies i.e. ‘read’ and ‘write’ should be visible in ‘Shared access policies’ blade.


Click on copy and note the Primary key associated with Shared access policies ‘read’ and ‘write’.



Create a new .NET Core project

Now we need to create two new projects to send and receive messages.

  • SendSample
  • ReceiveSample

SendSample Project

In Visual Studio, click on File / New / Project and select the project template Visual C# / .NET Core / Console App (.NET Core).


Add the following using statements to the top of the Program.cs file in SendSample Project

ReceiveSample Project

Add the following using statements to the top of the Program.cs file in ReceiveSample Project

In the property page that comes up, click on Startup Project and then choose Multiple startup projects: and change the Action for both queue projects to “Start”. Then click OK. Multiple-Project

In Visual Studio, click the Start button on the menu bar.


Now we can see two running console windows that should be showing some output.



To end with a quick recap. this blog helps you to send and receive messages through Queues using .NET Core. Also, you can use Azure Service Bus on multiple platforms like Windows, macOS, and Linux with ease!

Serverless360 is a one platform tool to operate, manage and monitor Azure Serverless components. It provides efficient tooling that is not and likely to be not available in Azure Portal. Try Serverless360 free for 15 days!