public async Task CloudQueueTestAnalyticsMetricsLevelAsync() { CloudQueueClient client = GenerateCloudQueueClient(); ServiceProperties props = await client.GetServicePropertiesAsync(); // None props.Metrics.MetricsLevel = MetricsLevel.None; props.Metrics.RetentionDays = null; props.Metrics.Version = "1.0"; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); // Service props.Metrics.MetricsLevel = MetricsLevel.Service; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); // ServiceAndAPI props.Metrics.MetricsLevel = MetricsLevel.ServiceAndApi; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); }
public async Task CloudQueueTestAnalyticsLoggingOperationsAsync() { CloudQueueClient client = GenerateCloudQueueClient(); ServiceProperties props = await client.GetServicePropertiesAsync(); // None props.Logging.LoggingOperations = LoggingOperations.None; props.Logging.RetentionDays = null; props.Logging.Version = "1.0"; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); // None props.Logging.LoggingOperations = LoggingOperations.All; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); }
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()); }
public void CloudQueueTestAnalyticsRoundTripTask() { props.Logging.LoggingOperations = LoggingOperations.Read | LoggingOperations.Write; props.Logging.RetentionDays = 5; props.Logging.Version = "1.0"; props.HourMetrics.MetricsLevel = MetricsLevel.Service; props.HourMetrics.RetentionDays = 6; props.HourMetrics.Version = "1.0"; client.SetServicePropertiesAsync(props).Wait(); TestHelper.AssertServicePropertiesAreEqual(props, client.GetServicePropertiesAsync().Result); }
public async Task CloudQueueClientServerTimeoutAsync() { CloudQueueClient client = GenerateCloudQueueClient(); string timeout = null; OperationContext context = new OperationContext(); context.SendingRequest += (sender, e) => { IDictionary <string, string> query = HttpWebUtility.ParseQueryString(e.RequestUri.Query); if (!query.TryGetValue("timeout", out timeout)) { timeout = null; } }; QueueRequestOptions options = new QueueRequestOptions(); await client.GetServicePropertiesAsync(null, context); Assert.IsNull(timeout); await client.GetServicePropertiesAsync(options, context); Assert.IsNull(timeout); options.ServerTimeout = TimeSpan.FromSeconds(100); await client.GetServicePropertiesAsync(options, context); Assert.AreEqual("100", timeout); client.DefaultRequestOptions.ServerTimeout = TimeSpan.FromSeconds(90); await client.GetServicePropertiesAsync(null, context); Assert.AreEqual("90", timeout); await client.GetServicePropertiesAsync(options, context); Assert.AreEqual("100", timeout); options.ServerTimeout = null; await client.GetServicePropertiesAsync(options, context); Assert.AreEqual("90", timeout); options.ServerTimeout = TimeSpan.Zero; await client.GetServicePropertiesAsync(options, context); Assert.IsNull(timeout); }
public async Task CloudQueueTestAnalyticsRoundTripAsync() { CloudQueueClient client = GenerateCloudQueueClient(); ServiceProperties props = new ServiceProperties(); props.Logging.LoggingOperations = LoggingOperations.Read | LoggingOperations.Write; props.Logging.RetentionDays = 5; props.Logging.Version = "1.0"; props.Metrics.MetricsLevel = MetricsLevel.Service; props.Metrics.RetentionDays = 6; props.Metrics.Version = "1.0"; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); }
public static void MyClassInitialize(TestContext testContext) { client = GenerateCloudQueueClient(); startProperties = client.GetServicePropertiesAsync().AsTask().Result; }
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()); }
public static void MyClassInitialize(TestContext testContext) { CloudQueueClient client = GenerateCloudQueueClient(); startProperties = client.GetServicePropertiesAsync().AsTask().Result; }
public async Task CloudQueueTestAnalyticsRetentionPoliciesAsync() { CloudQueueClient client = GenerateCloudQueueClient(); ServiceProperties props = await client.GetServicePropertiesAsync(); // Set retention policy null with metrics disabled. props.Metrics.RetentionDays = null; props.Metrics.MetricsLevel = MetricsLevel.None; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); // Set retention policy not null with metrics disabled. props.Metrics.RetentionDays = 1; props.Metrics.MetricsLevel = MetricsLevel.Service; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); // Set retention policy not null with metrics enabled. props.Metrics.MetricsLevel = MetricsLevel.ServiceAndApi; props.Metrics.RetentionDays = 2; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); // Set retention policy null with logging disabled. props.Logging.RetentionDays = null; props.Logging.LoggingOperations = LoggingOperations.None; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); // Set retention policy not null with logging disabled. props.Logging.RetentionDays = 3; props.Logging.LoggingOperations = LoggingOperations.None; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); // Set retention policy null with logging enabled. props.Logging.RetentionDays = null; props.Logging.LoggingOperations = LoggingOperations.All; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); // Set retention policy not null with logging enabled. props.Logging.RetentionDays = 4; props.Logging.LoggingOperations = LoggingOperations.All; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); }
public static async Task MyClassInitialize(TestContext testContext) { client = GenerateCloudQueueClient(); startProperties = await client.GetServicePropertiesAsync(); }
public async Task CloudQueueTestAnalyticsRoundTripAsync() { props.Logging.LoggingOperations = LoggingOperations.Read | LoggingOperations.Write; props.Logging.RetentionDays = 5; props.Logging.Version = "1.0"; props.HourMetrics.MetricsLevel = MetricsLevel.Service; props.HourMetrics.RetentionDays = 6; props.HourMetrics.Version = "1.0"; props.MinuteMetrics.MetricsLevel = MetricsLevel.Service; props.MinuteMetrics.RetentionDays = 6; props.MinuteMetrics.Version = "1.0"; props.Cors.CorsRules.Add( new CorsRule() { AllowedOrigins = new List <string>() { "www.ab.com", "www.bc.com" }, AllowedMethods = CorsHttpMethods.Get | CorsHttpMethods.Put, MaxAgeInSeconds = 500, ExposedHeaders = new List <string>() { "x-ms-meta-data*", "x-ms-meta-source*", "x-ms-meta-abc", "x-ms-meta-bcd" }, AllowedHeaders = new List <string>() { "x-ms-meta-data*", "x-ms-meta-target*", "x-ms-meta-xyz", "x-ms-meta-foo" } }); await client.SetServicePropertiesAsync(props); TestHelper.AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); }
/// <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(); }
/// <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(); }