Send messages to the queue
In order to send messages to the queue, we will write a C# console application using Visual Studio.
Create a console application
- Launch Visual Studio and create a new Console application.
Add the Service Bus NuGet package
- Right click on the newly created project and select Manage NuGet Packages.
- Click the Browse tab, then search for “Microsoft Azure Service Bus” and select the Microsoft Azure Service Bus item. Click Install to complete the installation, then close this dialog box.
- Select a NuGet package
Write some code to send a message to the queue
- Add the following using statement to the top of the Program.cs file.
- Add the following code to the Main method, set the connectionString variable as the connection string that was obtained when creating the namespace, and set queueName as the queue name that used when creating the queue.
- Here is what your Program.cs should look like.
- Run the program, and check the Azure classic portal. Notice that the Queue Length value should now be 1.
- Queue length