當前位置: 首頁>>代碼示例>>C#>>正文


C# CloudQueueClient.SetServicePropertiesAsync方法代碼示例

本文整理匯總了C#中Microsoft.WindowsAzure.Storage.Queue.CloudQueueClient.SetServicePropertiesAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# CloudQueueClient.SetServicePropertiesAsync方法的具體用法?C# CloudQueueClient.SetServicePropertiesAsync怎麽用?C# CloudQueueClient.SetServicePropertiesAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.WindowsAzure.Storage.Queue.CloudQueueClient的用法示例。


在下文中一共展示了CloudQueueClient.SetServicePropertiesAsync方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CorsSample

        /// <summary>
        /// Query the Cross-Origin Resource Sharing (CORS) rules for the Queue service
        /// </summary>
        /// <param name="queueClient"></param>
        private static async Task CorsSample(CloudQueueClient queueClient)
        {
            Console.WriteLine();

            // Get service properties
            Console.WriteLine("Get service properties");
            ServiceProperties originalProperties = await queueClient.GetServicePropertiesAsync();
            try
            {
                // Add CORS rule
                Console.WriteLine("Add CORS rule");

                CorsRule corsRule = new CorsRule
                {
                    AllowedHeaders = new List<string> {"*"},
                    AllowedMethods = CorsHttpMethods.Get,
                    AllowedOrigins = new List<string> {"*"},
                    ExposedHeaders = new List<string> {"*"},
                    MaxAgeInSeconds = 3600
                };

                ServiceProperties serviceProperties = await queueClient.GetServicePropertiesAsync();
                serviceProperties.Cors.CorsRules.Add(corsRule);
                await queueClient.SetServicePropertiesAsync(serviceProperties);
            }
            finally
            {
                // Revert back to original service properties
                Console.WriteLine("Revert back to original service properties");
                await queueClient.SetServicePropertiesAsync(originalProperties);
            }
            Console.WriteLine();
        }
開發者ID:Azure-Samples,項目名稱:storage-queue-dotnet-getting-started,代碼行數:37,代碼來源:Advanced.cs

示例2: TestCorsRulesAsync

        private async Task TestCorsRulesAsync(CloudQueueClient client, OperationContext context, IList<CorsRule> corsProps)
        {
            props.Cors.CorsRules.Clear();

            foreach (CorsRule rule in corsProps)
            {
                props.Cors.CorsRules.Add(rule);
            }

            await client.SetServicePropertiesAsync(props, null, context);
            TestHelper.AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync());
        }
開發者ID:benaadams,項目名稱:azure-storage-net,代碼行數:12,代碼來源:QueueAnalyticsUnitTests.cs

示例3: ServicePropertiesSample

        /// <summary>
        /// Manage the properties of the Queue service.
        /// </summary>
        /// <param name="queueClient"></param>
        private static async Task ServicePropertiesSample(CloudQueueClient queueClient)
        {
            Console.WriteLine();

            // Get service properties
            Console.WriteLine("Get service properties");
            ServiceProperties originalProperties = await queueClient.GetServicePropertiesAsync();
            try
            {
                // Set service properties
                Console.WriteLine("Set service properties");

                ServiceProperties props = await queueClient.GetServicePropertiesAsync();
                props.Logging.LoggingOperations = LoggingOperations.Read | LoggingOperations.Write;
                props.Logging.RetentionDays = 5;
                props.Logging.Version = Constants.AnalyticsConstants.LoggingVersionV1;

                props.HourMetrics.MetricsLevel = MetricsLevel.Service;
                props.HourMetrics.RetentionDays = 6;
                props.HourMetrics.Version = Constants.AnalyticsConstants.MetricsVersionV1;

                props.MinuteMetrics.MetricsLevel = MetricsLevel.Service;
                props.MinuteMetrics.RetentionDays = 6;
                props.MinuteMetrics.Version = Constants.AnalyticsConstants.MetricsVersionV1;

                await queueClient.SetServicePropertiesAsync(props);
            }
            finally
            {
                // Revert back to original service properties
                Console.WriteLine("Revert back to original service properties");
                await queueClient.SetServicePropertiesAsync(originalProperties);
            }
            Console.WriteLine();
        }
開發者ID:Azure-Samples,項目名稱:storage-queue-dotnet-getting-started,代碼行數:39,代碼來源:Advanced.cs


注:本文中的Microsoft.WindowsAzure.Storage.Queue.CloudQueueClient.SetServicePropertiesAsync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。