简体   繁体   English

有什么方法可以从.Net内部创建Azure Service Bus命名空间?

[英]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.FluentMicrosoft.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.

相关问题 如何在 azure 服务总线命名空间中创建主题、订阅和 SAS 策略? - How to create topic, subscription and SAS policy in azure service bus namespace? Azure 服务总线配对命名空间 - 模拟故障转移 - Azure service bus paired namespace - simulate failover 从 .net 5 中的 Azure 服务总线队列获取消息 ID - Get message id from Azure Service Bus Queue in .net 5 在.NET的Azure管理库中创建具有多个声明的Azure服务总线策略 - Create Azure Service Bus policy with multiple claims in Azure Management libraries for .NET Asp.net样板和Azure服务总线 - Asp.net Boilerplate and Azure Service Bus 在 Azure 函数中将服务总线与 SQL Server 一起使用的最有效方法是什么? - What is the most efficient way of using service bus together with SQL Server within Azure functions? 如何通过应用程序在 azure 的服务总线中创建队列 - How to create queue in service bus in azure by application Azure 服务总线:从对象创建 BrokeredMessage - Azure Service Bus: Creating a BrokeredMessage from Object 从 ASP.NET Core 2.0 控制台应用程序监控 Azure 服务总线队列深度 - Monitoring Azure Service Bus Queue Depth from ASP.NET Core 2.0 Console App 从 Azure 服务总线主题读取的 Asp.net Core 2.2 - Asp.net Core 2.2 read from Azure Service Bus Topic
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM