[英]Is there any way to create a azure service bus namespace from within .Net?
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. 我们正在使用.Net framework 4.6.x,正在寻找一种从azure.management sdk创建azure服务总线名称空间的方法。 We are having trouble implementing programmatically within .Net with C#, Any reference or direct documentation would be helpful.
我们在使用C#在.Net中以编程方式实现时遇到了麻烦,任何参考或直接文档都将有所帮助。 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.
msdn上的文档似乎利用了旧的REST api,由于Windows已执行相同的操作,因此我们现在需要升级。 Any direction or references that do not create the service bus in the physical portal or use the REST api.
没有在物理门户中创建服务总线或使用REST API的任何方向或参考。
We could use the Azure fluent SDK Microsoft.Azure.Management.Fluent and Microsoft.Azure.Management.ResourceManager.Fluent to do that. 我们可以使用Azure流畅的SDK Microsoft.Azure.Management.Fluent和Microsoft.Azure.Management.ResourceManager.Fluent来实现。 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.
关于如何获取Azure凭据文件,我们可以参考Azure管理库中用于.NET的身份验证,我使用了身份验证文件。
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 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.