This post lets us create a publisher and subscriber messaging app using Azure Web PubSub Service and C#. In the previous post, Getting Started with Azure Web PubSub Service; we have learned how to create Azure Web PubSub Service in the Azure Portal and tested the messaging using one sample application. This post will use the Azure SDK client library for the Web PubSub service to build a simple messaging application using C#.

Getting Started with Azure Web PubSub Service

Messaging App using Azure Web PubSub Service

To start with, create a Blank Solution in Visual Studio, and add two console projects “AzureWebPubSubDemoPublisher” and “AzureWebPubSubDemoSubscriber“. Once you are done with that, your solution structure will look like the following.

Create the Publisher

Firstly, let us start create the publisher App. Add “Azure.Messaging.WebPubSub” NuGet package to the solution.

Once the package is added, the solution structure will looks like follows.

Replace the program.cs code with the following code block and update the **Keys **and **Hub **Name generated from the portal.

#azure #azure web pubsub

Create a Messaging App using Azure Web PubSub Service and C#
1.45 GEEK