代码之家  ›  专栏  ›  技术社区  ›  Brent Robinson

在.NET的Azure管理库中创建具有多个声明的Azure服务总线策略

  •  0
  • Brent Robinson  · 技术社区  · 7 年前

    我在用电话 Azure Management libraries for .NET 发送 声称。我可以在Azure门户中执行此操作。

    Policy created in the azure portal

    IServiceBusNamespace serviceBus = ...
    IBlank policyDefinition = serviceBus.AuthorizationRules.Define("MySendAndListenPolicy2");
    

    从…起 IBlank WithListeningEnabled() WithSendingEnabled() IWithCreate ,我只能从中创建规则(即。 Create() CreateAsync() . 似乎没有一个选项可以同时配置这两者 发送

    如何使用创建策略 发送 使用Azure管理.NET SDK?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Brent Robinson    7 年前

    我通过使用 内部的

    // using Microsoft.Azure.Management.Fluent;
    // using Microsoft.Azure.Management.ServiceBus.Fluent;
    // using Microsoft.Azure.Management.ServiceBus.Fluent.Models;
    
    string policyName = "ListenAndSendPolicy";
    
    // Define the claims
    IList<AccessRights?> rights = new List<AccessRights?>();
    rights.Add(AccessRights.Send);
    rights.Add(AccessRights.Listen);
    
    // Create the rule
    SharedAccessAuthorizationRuleInner rule = await serviceBus.AuthorizationRules.Inner.CreateOrUpdateAuthorizationRuleAsync(
        serviceBus.ResourceGroupName,
        serviceBus.Name,
        policyName,
        rights);
    
    // Get the policy
    policy = await serviceBus.AuthorizationRules.GetByNameAsync(policyName);
    

    这成功地创建了策略

    enter image description here

    推荐文章