-1

Below is the code in .NET framework.what is the equivalent code in .net core using microsoft.azure.servicebus library

var namespaceManager = NamespaceManager.CreateFromConnectionString(ServiceBusConnectionString);
        if (!namespaceManager.TopicExists(topicName))
        {      // Configure Topic Settings.
            var td = new TopicDescription(topicName);
            td.MaxSizeInMegabytes = 1024;
            td.DefaultMessageTimeToLive = TimeSpan.FromMinutes(5);

            namespaceManager.CreateTopic(td);
        }
  • See whether this link helps: https://www.example-code.com/dotnet-core/azure_service_bus_create_topic.asp – Joy Wang Jul 09 '18 at 05:47

1 Answers1

0

You also could get this issue from Azure SDK github. Please refer to Azure Service bus github to get more information.

The standard way to manage Azure resources is by using Azure Resource Manager. In order to use functionality that previously existed in the .NET Framework Service Bus client library, you will need to use the Microsoft.Azure.Management.ServiceBus library. This will enable use cases that dynamically create/read/update/delete resources.

Currently, we could use the Azure fluent SDK Microsoft.Azure.Management.Fluent and Microsoft.Azure.Management.ResourceManager.Fluent to do that. About how to create auth file please refer to another SO thread.

var azureCredentials = SdkContext.AzureCredentialsFactory.FromFile("authfile paht"); // or different way
var azure = Azure
               .Configure()
               .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
               .Authenticate(azureCredentials)
               .WithDefaultSubscription();
var sbNameSpace = "service bus name space";
var resoureGroup = "resourcegroup";
var serviceBusNamespace = azure.ServiceBusNamespaces.GetByResourceGroup(resoureGroup, sbNameSpace);
serviceBusNamespace.Topics
                   .Define("topicName")
                   .WithSizeInMB(1024)
                   .WithDefaultMessageTTL(TimeSpan.FromMinutes(5))
                   .Create();
Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
  • can you please be more clear like what does azure credentials mean? – bhargav porapu Jul 09 '18 at 08:48
  • Sorry for missing the [link](https://stackoverflow.com/questions/48104773/is-there-any-way-to-create-a-azure-service-bus-namespace-from-within-net/48106623#48106623), I also updated my answer. – Tom Sun - MSFT Jul 09 '18 at 08:57
  • what is client and key in that authfile? – bhargav porapu Jul 09 '18 at 09:25
  • @bhargavporapu You need to registry an Azure AD application, for more information please refer to this [toturial](https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) – Tom Sun - MSFT Jul 09 '18 at 09:53
  • can we create a topic in azure namespace without using azure resource management? – bhargav porapu Jul 10 '18 at 07:38
  • Based on my knowledge, currently **no**. – Tom Sun - MSFT Jul 10 '18 at 07:39
  • can we create subscription for a topic in azure namespace without using azure resource management? if yes how – bhargav porapu Jul 10 '18 at 11:19
  • Unfortunately, no. If we want to management(create/list/update) the servicebus resources. Currently we need to use azure resource management. If use https://github.com/Mossharbor/AzureWorkArounds.ServiceBus is possible, you could have a try – Tom Sun - MSFT Jul 11 '18 at 00:51