I tried in my environment and got below results:
Make sure you were using latest version of NuGet package for Azure-Messaging-ServiceBus- 7.11.1 in your environment because Microsoft.Azure.ServiceBus
is deprecated
.
Initially, I created service bus with topic and subscription through portal using this Document and sending 5 messages to the topic.
Sending messages to the topic with below code:
using System.Diagnostics;
using System;
using System.Threading.Tasks;
using Azure.Messaging.ServiceBus;
ServiceBusClient client;
ServiceBusSender sender;
const int numOfMessages = 5;
client = new ServiceBusClient("<connect strng >");
sender = client.CreateSender("topicname");
using ServiceBusMessageBatch messageBatch = await sender.CreateMessageBatchAsync();
for (int i = 1; i <= numOfMessages; i++)
{
if (!messageBatch.TryAddMessage(new ServiceBusMessage($"Message {i}")))
{
throw new Exception($"The message {i} is too large to fit in the batch.");
}
}
try
{
await sender.SendMessagesAsync(messageBatch);
Console.WriteLine($"A batch of {numOfMessages} messages has been published to the topic.");
}
finally
{
await sender.DisposeAsync();
await client.DisposeAsync();
}
Console.WriteLine("Press any key to end the application");
Console.ReadKey();
Console:

Portal:
In portal you can check in the overview tab of incoming messages is 5.

Receiving messages from a subscription with below code:
using System;
using System.Threading.Tasks;
using Azure.Messaging.ServiceBus;
ServiceBusClient client;
ServiceBusProcessor processor;
async Task MessageHandler(ProcessMessageEventArgs args)
{
string body = args.Message.Body.ToString();
Console.WriteLine($"Received: {body} from subscription.");
await args.CompleteMessageAsync(args.Message);
}
Task ErrorHandler(ProcessErrorEventArgs args)
{
Console.WriteLine(args.Exception.ToString());
return Task.CompletedTask;
}
client = new ServiceBusClient("connect strng");
processor = client.CreateProcessor("topicname", "subscriptionname", new ServiceBusProcessorOptions());
try
{
processor.ProcessMessageAsync += MessageHandler;
processor.ProcessErrorAsync += ErrorHandler;
await processor.StartProcessingAsync();
Console.WriteLine("Wait for a minute and then press any key to end the processing");
Console.ReadKey();
Console.WriteLine("\nStopping the receiver...");
Console.WriteLine("Stopped receiving messages");
}
finally
{
await processor.DisposeAsync();
await client.DisposeAsync();
}
Console:
The above code executed successfully and received messages from subscription.

Portal:

Portal:

At last, in your Service Bus Subscription
level page, you see the Active message count
as zero. Because it tells receiver has read and finished messages from this subscription.