Microsoft.WindowsAzure.Commands.Utilities.ServiceBus.ServiceBusClientExtensions.CreateSharedAccessAuthorization C# (CSharp) Méthode

CreateSharedAccessAuthorization() public méthode

Creates shared access signature authorization for the service bus entity. This authorization works on public Microsoft Azure environments and Windows Azure Pack on prim as well.
public CreateSharedAccessAuthorization ( string namespaceName, string entityName, ServiceBusEntityType entityType, string ruleName, string primaryKey, string secondaryKey ) : Microsoft.WindowsAzure.Commands.Utilities.ServiceBus.ExtendedAuthorizationRule
namespaceName string The service bus namespace name
entityName string The fully qualified service bus entity name
entityType ServiceBusEntityType The service bus entity type (e.g. Queue)
ruleName string The SAS authorization rule name
primaryKey string The SAS primary key. It'll be generated if empty
secondaryKey string The SAS secondary key
Résultat Microsoft.WindowsAzure.Commands.Utilities.ServiceBus.ExtendedAuthorizationRule
        public virtual ExtendedAuthorizationRule CreateSharedAccessAuthorization(
            string namespaceName,
            string entityName,
            ServiceBusEntityType entityType,
            string ruleName,
            string primaryKey,
            string secondaryKey,
            params AccessRights[] permissions)
        {
            // Create the SAS authorization rule
            SharedAccessAuthorizationRule rule = new SharedAccessAuthorizationRule(
                ruleName,
                string.IsNullOrEmpty(primaryKey) ? SharedAccessAuthorizationRule.GenerateRandomKey() : primaryKey,
                secondaryKey,
                permissions);

            // Create namespace manager
            NamespaceManager namespaceManager = CreateNamespaceManager(namespaceName);

            // Add the SAS rule and update the entity
            switch (entityType)
            {
                case ServiceBusEntityType.Queue:
                    QueueDescription queue = namespaceManager.GetQueue(entityName);
                    queue.Authorization.Add(rule);
                    namespaceManager.UpdateQueue(queue);
                    break;

                case ServiceBusEntityType.Topic:
                    TopicDescription topic = namespaceManager.GetTopic(entityName);
                    topic.Authorization.Add(rule);
                    namespaceManager.UpdateTopic(topic);
                    break;

                case ServiceBusEntityType.Relay:
                    RelayDescription relay = namespaceManager.GetRelayAsync(entityName).Result;
                    relay.Authorization.Add(rule);
                    namespaceManager.UpdateRelayAsync(relay).Wait();
                    break;

                case ServiceBusEntityType.NotificationHub:
                    NotificationHubDescription notificationHub = namespaceManager.GetNotificationHub(entityName);
                    notificationHub.Authorization.Add(rule);
                    namespaceManager.UpdateNotificationHub(notificationHub);
                    break;

                default:
                    throw new Exception(string.Format(Resources.ServiceBusEntityTypeNotFound, entityType.ToString()));
            }
            
            return CreateExtendedAuthorizationRule(rule, namespaceName, entityName, entityType);
        }

Same methods

ServiceBusClientExtensions::CreateSharedAccessAuthorization ( string namespaceName, string ruleName, string primaryKey, string secondaryKey ) : Microsoft.WindowsAzure.Commands.Utilities.ServiceBus.ExtendedAuthorizationRule