We are using .Net framework 4.6.x and looking for a way to create an azure service bus namespace from the azure.management sdk. We are having trouble implementing programmatically within .Net with C#, Any reference or direct documentation would be helpful. The documentation on msdn seems to utilize the old REST api, we need to upgrade away from this now since windows has done the same. Any direction or references that do not create the service bus in the physical portal or use the REST api.
Asked
Active
Viewed 1,142 times
1
-
Try this https://code.msdn.microsoft.com/Service-Bus-Resource-5d887203 – Chetan Jan 04 '18 at 23:37
-
The code.msdn.microsoft.com link is unfortunately dead; it redirects to a set of samples that don't seem to include the sample referenced above. – Suman Dec 03 '19 at 02:02
1 Answers
2
We could use the Azure fluent SDK Microsoft.Azure.Management.Fluent and Microsoft.Azure.Management.ResourceManager.Fluent to do that. I also test it on my side. It works correctly on my side. About how to get the azure credential file, we could refer to Authentication in Azure Management Libraries for .NET I used an authentication file.
subscription=########-####-####-####-############
client=########-####-####-####-############
tenant=########-####-####-####-############
key=XXXXXXXXXXXXXXXX
managementURI=https\://management.core.windows.net/
baseURL=https\://management.azure.com/
authURL=https\://login.windows.net/
graphURL=https\://graph.windows.net/
Demo code.
using Microsoft.Azure.Management.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent.Core;
using Microsoft.Azure.Management.ServiceBus.Fluent;
namespace CreateServiceBus
{
class Program
{
static void Main(string[] args)
{
var credentials = SdkContext.AzureCredentialsFactory.FromFile(@"C:\Tom\azureCredential.txt");
var azure = Azure
.Configure()
.WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
.Authenticate(credentials)
.WithDefaultSubscription();
var sbNameSpace = "service bus name space";
var resoureGroup = "resourcegroup";
var serviceBusNamespace = azure.ServiceBusNamespaces
.Define(sbNameSpace)
.WithRegion(Region.USEast)
.WithNewResourceGroup(resoureGroup)
.WithSku(NamespaceSku.Basic)
.Create();
}
}
}
Packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.Management.AppService.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.Batch.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.Cdn.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.Compute.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.Dns.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.Graph.RBAC.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.KeyVault.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.Network.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.Redis.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.ResourceManager.Fluent" version="1.1.3" targetFramework="net462" />
<package id="Microsoft.Azure.Management.ServiceBus.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.Sql.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.Storage.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.Azure.Management.TrafficManager.Fluent" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.28.3" targetFramework="net462" />
<package id="Microsoft.Rest.ClientRuntime" version="2.3.8" targetFramework="net462" />
<package id="Microsoft.Rest.ClientRuntime.Azure" version="3.3.8" targetFramework="net462" />
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.3.0" targetFramework="net462" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net462" />
</packages>

Tom Sun - MSFT
- 24,161
- 3
- 30
- 47
-
Is it possible to get an access key of the newly created namespace? I'm building a test application which needs to create namespaces on the fly, and also create queues/topics on the fly. Then send/receive messages. The problem is I need a connection string (with access key) to create a ServiceBusClient properly. I'm using the latest Azure.Messaging.ServiceBus library to create queues/topics and to send/receive messages. I'm using the older Microsoft.Azure.Management.ServiceBus library to create namespaces. – killswitch May 07 '21 at 14:36