Пример #1
0
        public TopicAttributes CreateUpdateTopic(string resourceGroupName, string namespaceName, string topicName, TopicAttributes topic)
        {
            var parameters = new TopicCreateOrUpdateParameters()
            {
                AutoDeleteOnIdle                    = topic.AutoDeleteOnIdle,
                EntityAvailabilityStatus            = topic.EntityAvailabilityStatus,
                DefaultMessageTimeToLive            = topic.DefaultMessageTimeToLive,
                DuplicateDetectionHistoryTimeWindow = topic.DuplicateDetectionHistoryTimeWindow,
                EnableBatchedOperations             = topic.EnableBatchedOperations,
                EnableExpress                     = topic.EnableExpress,
                EnablePartitioning                = topic.EnablePartitioning,
                EnableSubscriptionPartitioning    = topic.EnableSubscriptionPartitioning,
                FilteringMessagesBeforePublishing = topic.FilteringMessagesBeforePublishing,
                IsAnonymousAccessible             = topic.IsAnonymousAccessible,
                IsExpress                  = topic.IsExpress,
                MaxSizeInMegabytes         = topic.MaxSizeInMegabytes,
                RequiresDuplicateDetection = topic.RequiresDuplicateDetection,
                Status          = topic.Status,
                SupportOrdering = topic.SupportOrdering,
                Location        = topic.Location
            };

            var response = Client.Topics.CreateOrUpdate(resourceGroupName, namespaceName, topicName, parameters);

            return(new TopicAttributes(response));
        }
        private static async Task CreateTopic()
        {
            try
            {
                if (string.IsNullOrEmpty(namespaceName))
                {
                    throw new Exception("Namespace name is empty!");
                }

                var token = await GetToken();

                var creds    = new TokenCredentials(token);
                var sbClient = new ServiceBusManagementClient(creds)
                {
                    SubscriptionId = SettingsCache["SubscriptionId"]
                };

                var topicParams = new TopicCreateOrUpdateParameters()
                {
                    Location           = SettingsCache["DataCenterLocation"],
                    EnablePartitioning = true
                };

                Console.WriteLine("Creating topic...");
                await sbClient.Topics.CreateOrUpdateAsync(resourceGroupName, namespaceName, TopicName, topicParams);

                Console.WriteLine("Created topic successfully.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Could not create a topic...");
                Console.WriteLine(e.Message);
                throw e;
            }
        }
Пример #3
0
        public TopicAttributes UpdateTopic(string resourceGroupName, string namespaceName, string topicName, string location, bool enableExpress, bool isAnonymousAccessible)
        {
            TopicCreateOrUpdateParameters parameters = new TopicCreateOrUpdateParameters()
            {
                Location              = location,
                EnableExpress         = enableExpress,
                IsAnonymousAccessible = isAnonymousAccessible
            };

            var response = Client.Topics.CreateOrUpdate(resourceGroupName, namespaceName, topicName, parameters);

            return(new TopicAttributes(response));
        }