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); QueueDescription description = await mgmtClient.CreateQueueAsync(queueName); // Changing Last Updated Time description.AutoDeleteOnIdle = TimeSpan.FromMinutes(100); QueueDescription updatedQueue = await mgmtClient.UpdateQueueAsync(description); // Populating 1 active message, 1 dead letter message and 1 scheduled message // Changing Last Accessed Time ServiceBusSender sender = sbClient.CreateSender(queueName); await sender.SendAsync(new ServiceBusMessage() { MessageId = "1" }); await sender.SendAsync(new ServiceBusMessage() { MessageId = "2" }); await sender.SendAsync(new ServiceBusMessage() { MessageId = "3", ScheduledEnqueueTime = DateTime.UtcNow.AddDays(1) }); ServiceBusReceiver receiver = sbClient.CreateReceiver(queueName); ServiceBusReceivedMessage msg = await receiver.ReceiveAsync(); await receiver.DeadLetterAsync(msg.LockToken); List <QueueRuntimeInfo> runtimeInfoList = new List <QueueRuntimeInfo>(); await foreach (QueueRuntimeInfo queueRuntimeInfo in mgmtClient.GetQueuesRuntimeInfoAsync()) { 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"); QueueRuntimeInfo 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.CountDetails.ActiveMessageCount); Assert.AreEqual(1, runtimeInfo.CountDetails.DeadLetterMessageCount); Assert.AreEqual(1, runtimeInfo.CountDetails.ScheduledMessageCount); Assert.AreEqual(3, runtimeInfo.MessageCount); Assert.True(runtimeInfo.SizeInBytes > 0); QueueRuntimeInfo singleRuntimeInfo = await mgmtClient.GetQueueRuntimeInfoAsync(runtimeInfo.Name); Assert.AreEqual(runtimeInfo.AccessedAt, singleRuntimeInfo.AccessedAt); Assert.AreEqual(runtimeInfo.CreatedAt, singleRuntimeInfo.CreatedAt); Assert.AreEqual(runtimeInfo.UpdatedAt, singleRuntimeInfo.UpdatedAt); Assert.AreEqual(runtimeInfo.MessageCount, singleRuntimeInfo.MessageCount); Assert.AreEqual(runtimeInfo.CountDetails.ActiveMessageCount, singleRuntimeInfo.CountDetails.ActiveMessageCount); Assert.AreEqual(runtimeInfo.CountDetails.DeadLetterMessageCount, singleRuntimeInfo.CountDetails.DeadLetterMessageCount); Assert.AreEqual(runtimeInfo.CountDetails.ScheduledMessageCount, singleRuntimeInfo.CountDetails.ScheduledMessageCount); Assert.AreEqual(runtimeInfo.SizeInBytes, singleRuntimeInfo.SizeInBytes); await mgmtClient.DeleteQueueAsync(queueName); }