public async Task GetQueueRuntimeInfo() { var queueName = nameof(GetQueueRuntimeInfo).ToLower() + Guid.NewGuid().ToString("D").Substring(0, 8); var mgmtClient = new ServiceBusManagementClient(TestEnvironment.ServiceBusConnectionString); await using var sbClient = new ServiceBusClient(TestEnvironment.ServiceBusConnectionString); QueueProperties queue = await mgmtClient.CreateQueueAsync(queueName); queue = await mgmtClient.GetQueueAsync(queueName); // Changing Last Updated Time queue.AutoDeleteOnIdle = TimeSpan.FromMinutes(100); QueueProperties updatedQueue = await mgmtClient.UpdateQueueAsync(queue); // Populating 1 active message, 1 dead letter message and 1 scheduled message // Changing Last Accessed Time ServiceBusSender sender = sbClient.CreateSender(queueName); await sender.SendMessageAsync(new ServiceBusMessage() { MessageId = "1" }); await sender.SendMessageAsync(new ServiceBusMessage() { MessageId = "2" }); await sender.SendMessageAsync(new ServiceBusMessage() { MessageId = "3", ScheduledEnqueueTime = DateTime.UtcNow.AddDays(1) }); ServiceBusReceiver receiver = sbClient.CreateReceiver(queueName); ServiceBusReceivedMessage msg = await receiver.ReceiveMessageAsync(); await receiver.DeadLetterMessageAsync(msg.LockToken); List <QueueRuntimeProperties> runtimeInfoList = new List <QueueRuntimeProperties>(); await foreach (QueueRuntimeProperties queueRuntimeInfo in mgmtClient.GetQueuesRuntimePropertiesAsync()) { runtimeInfoList.Add(queueRuntimeInfo); } runtimeInfoList = runtimeInfoList.Where(e => e.Name.StartsWith(nameof(GetQueueRuntimeInfo).ToLower())).ToList(); Assert.True(runtimeInfoList.Count == 1, $"Expected 1 queue but {runtimeInfoList.Count} queues returned"); QueueRuntimeProperties runtimeInfo = runtimeInfoList.First(); Assert.NotNull(runtimeInfo); Assert.AreEqual(queueName, runtimeInfo.Name); Assert.True(runtimeInfo.CreatedAt < runtimeInfo.UpdatedAt); Assert.True(runtimeInfo.UpdatedAt < runtimeInfo.AccessedAt); Assert.AreEqual(1, runtimeInfo.ActiveMessageCount); Assert.AreEqual(1, runtimeInfo.DeadLetterMessageCount); Assert.AreEqual(1, runtimeInfo.ScheduledMessageCount); Assert.AreEqual(3, runtimeInfo.TotalMessageCount); Assert.True(runtimeInfo.SizeInBytes > 0); QueueRuntimeProperties singleRuntimeInfo = await mgmtClient.GetQueueRuntimePropertiesAsync(runtimeInfo.Name); Assert.AreEqual(runtimeInfo.AccessedAt, singleRuntimeInfo.AccessedAt); Assert.AreEqual(runtimeInfo.CreatedAt, singleRuntimeInfo.CreatedAt); Assert.AreEqual(runtimeInfo.UpdatedAt, singleRuntimeInfo.UpdatedAt); Assert.AreEqual(runtimeInfo.TotalMessageCount, singleRuntimeInfo.TotalMessageCount); Assert.AreEqual(runtimeInfo.ActiveMessageCount, singleRuntimeInfo.ActiveMessageCount); Assert.AreEqual(runtimeInfo.DeadLetterMessageCount, singleRuntimeInfo.DeadLetterMessageCount); Assert.AreEqual(runtimeInfo.ScheduledMessageCount, singleRuntimeInfo.ScheduledMessageCount); Assert.AreEqual(runtimeInfo.SizeInBytes, singleRuntimeInfo.SizeInBytes); await mgmtClient.DeleteQueueAsync(queueName); }