Programmatically create service bus subscription using .net standard

Original plan for the new Azure Service Bus client was not to include management plane at all and use Azure Active Directory route instead. This has proven to be too problematic, just like you've pointed out. Microsoft messaging team has put together a sample to demonstrate the basic operations.

Note that there's a pending PR to get it working with .NET Core 2.0

Moving forward, it was recognized that developers prefer to access Service Bass using a connection string like they used to over Azure Active Directory option. Management Operations issue is raised to track requests. Current plan is to provide a light weight management library for the .NET Standard client.

For now, the options are either to leverage the old client to create entities or use Microsoft.Azure.Management.ServiceBus (or Fluent) until the management package is available.

Update

Management operations were released as part of 3.1.0 version of the client.


Microsoft.Azure.ServiceBus.3.1.0 allows to create a ManagementClient using the ConnectionString.

private async Task CreateTopicSubscriptions()
{
    var client = new ManagementClient(ServiceBusConnectionString);
    for (int i = 0; i < Subscriptions.Length; i++)
    {
        if (!await client.SubscriptionExistsAsync(TopicName, Subscriptions[i]))
        {
            await client.CreateSubscriptionAsync(new SubscriptionDescription(TopicName, Subscriptions[i]));
        }
    }
}