Getting Azure Service Bus Queue ActiveMessageCount with .Net Core and C#

Couple of days ago I needed to get ActiveMessageCount
property from Azure Service Bus Queue, which didn’t look like complicated task. In fact, it is not a complicated problem, but with all the functionality migrations and refactorings on Microsoft side, documentation became a bit messy and I have spent good 2 hours digging for the solution.
It’s 3 lines of code once you find where to look:
var managementClient = new ManagementClient("queue connection string"));var runtimeInfo = await managementClient.GetQueueRuntimeInfoAsync("queueName");
var messagesInQueueCount = runtimeInfo.MessageCountDetails.ActiveMessageCount;
For this code to work, you need Microsoft.Azure.ServiceBus nuget package or any one that has this package in dependencies.