public async Task CloudBlobTestAnalyticsMetricsLevelAsync() { CloudBlobClient client = GenerateCloudBlobClient(); 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 CloudBlobTestAnalyticsLoggingOperationsAsync() { CloudBlobClient client = GenerateCloudBlobClient(); 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()); }
public void CloudBlobTestAnalyticsRoundTripTask() { 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; client.SetServicePropertiesAsync(props).Wait(); // Wait for analytics server to update TestHelper.SpinUpTo30SecondsIgnoringFailures(() => TestHelper.AssertServicePropertiesAreEqual(props, client.GetServicePropertiesAsync().Result)); }
public void CloudBlobTestAnalyticsRoundTripTask() { 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; client.SetServicePropertiesAsync(props).Wait(); // Wait for analytics server to update Thread.Sleep(60 * 1000); TestHelper.AssertServicePropertiesAreEqual(props, client.GetServicePropertiesAsync().Result); }
internal static void DisableSoftDelete(this CloudBlobClient client) { ServiceProperties props = new ServiceProperties( deleteRetentionPolicy: new DeleteRetentionPolicy() { Enabled = false } ); client.SetServicePropertiesAsync(props).Wait(); }
private async Task TestCorsRulesAsync(CloudBlobClient 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 async Task CloudBlobTestAnalyticsDefaultServiceVersionAsync() { CloudBlobClient client = GenerateCloudBlobClient(); ServiceProperties props = await client.GetServicePropertiesAsync(); props.DefaultServiceVersion = "2009-09-19"; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); props.DefaultServiceVersion = "2011-08-18"; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); props.DefaultServiceVersion = "2012-02-12"; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); props.DefaultServiceVersion = null; await client.SetServicePropertiesAsync(props); // Wait for analytics server to update await Task.Delay(60 * 1000); AssertServicePropertiesAreEqual(props, await client.GetServicePropertiesAsync()); }
internal static void DisableSoftDelete(this CloudBlobClient client) { ServiceProperties props = new ServiceProperties( deleteRetentionPolicy: new DeleteRetentionPolicy() { Enabled = false } ); client.SetServicePropertiesAsync(props).Wait(); #if NETCORE Thread.Sleep(30000); #else Task.Delay(TimeSpan.FromSeconds(30)).Wait(); #endif }
public void BlobGetSetServicePropertiesTask() { CloudBlobClient blobClient = GenerateCloudBlobClient(); ServiceProperties serviceProperties = new ServiceProperties(); serviceProperties.Logging.LoggingOperations = LoggingOperations.Read | LoggingOperations.Write | LoggingOperations.Delete; serviceProperties.Logging.RetentionDays = 8; serviceProperties.Logging.Version = "1.0"; serviceProperties.Metrics.MetricsLevel = MetricsLevel.Service; serviceProperties.Metrics.RetentionDays = 8; serviceProperties.Metrics.Version = "1.0"; blobClient.SetServicePropertiesAsync(serviceProperties).Wait(); ServiceProperties actual = blobClient.GetServicePropertiesAsync().Result; AssertServicePropertiesAreEqual(serviceProperties, actual); }
public void CloudBlobTestAnalyticsRoundTripTask() { CloudBlobClient client = GenerateCloudBlobClient(); 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"; client.SetServicePropertiesAsync(props).Wait(); // Wait for analytics server to update Thread.Sleep(60 * 1000); AssertServicePropertiesAreEqual(props, client.GetServicePropertiesAsync().Result); }
internal static void EnableSoftDelete(this CloudBlobClient client) { ServiceProperties props = new ServiceProperties( new LoggingProperties(), new MetricsProperties(), new MetricsProperties(), new CorsProperties(), new DeleteRetentionPolicy() { Enabled = true, RetentionDays = 1 } ); client.SetServicePropertiesAsync(props).Wait(); #if NETCORE Thread.Sleep(30000); #else Task.Delay(TimeSpan.FromSeconds(30)).Wait(); #endif }
public void BlobGetSetServicePropertiesRequestOptionsOperationContextTask() { CloudBlobClient blobClient = GenerateCloudBlobClient(); BlobRequestOptions requestOptions = new BlobRequestOptions(); OperationContext operationContext = new OperationContext(); ServiceProperties serviceProperties = new ServiceProperties(); serviceProperties.Logging.LoggingOperations = LoggingOperations.Read | LoggingOperations.Write | LoggingOperations.Delete; serviceProperties.Logging.RetentionDays = 10; serviceProperties.Logging.Version = "1.0"; serviceProperties.Metrics.MetricsLevel = MetricsLevel.Service; serviceProperties.Metrics.RetentionDays = 10; serviceProperties.Metrics.Version = "1.0"; blobClient.SetServicePropertiesAsync(serviceProperties, requestOptions, operationContext).Wait(); ServiceProperties actual = blobClient.GetServicePropertiesAsync(requestOptions, operationContext).Result; AssertServicePropertiesAreEqual(serviceProperties, actual); }
public async Task CloudBlobTestAnalyticsRoundTripAsync() { CloudBlobClient client = GenerateCloudBlobClient(); 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 MyClassCleanup() { CloudBlobClient client = GenerateCloudBlobClient(); client.SetServicePropertiesAsync(startProperties).AsTask().Wait(); }
public static void MyClassCleanup() { client.SetServicePropertiesAsync(startProperties).AsTask().Wait(); }
private async Task TestCorsRulesAsync(CloudBlobClient 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()); }
/// <summary> /// Query the Cross-Origin Resource Sharing (CORS) rules for the Queue service /// </summary> /// <param name="blobClient"></param> private static async Task CorsSample(CloudBlobClient blobClient) { // Get CORS rules Console.WriteLine("Get CORS rules"); ServiceProperties serviceProperties = await blobClient.GetServicePropertiesAsync(); // 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.Cors.CorsRules.Add(corsRule); await blobClient.SetServicePropertiesAsync(serviceProperties); Console.WriteLine(); }
/// <summary> /// Configures logging and metrics for Blob storage, as well as the default service version. /// Note that if you have already enabled analytics for your storage account, running this sample /// will change those settings. For that reason, it's best to run with a test storage account if possible. /// The sample saves your settings and resets them after it has completed running. /// </summary> /// <param name="blobClient">The Blob service client.</param> /// <returns>A Task object.</returns> private static async Task ConfigureBlobAnalyticsAsync(CloudBlobClient blobClient) { try { // Get current service property settings. ServiceProperties serviceProperties = await blobClient.GetServicePropertiesAsync(); // Enable analytics logging and set retention policy to 14 days. serviceProperties.Logging.LoggingOperations = LoggingOperations.All; serviceProperties.Logging.RetentionDays = 14; serviceProperties.Logging.Version = "1.0"; // Configure service properties for hourly and minute metrics. // Set retention policy to 7 days. serviceProperties.HourMetrics.MetricsLevel = MetricsLevel.ServiceAndApi; serviceProperties.HourMetrics.RetentionDays = 7; serviceProperties.HourMetrics.Version = "1.0"; serviceProperties.MinuteMetrics.MetricsLevel = MetricsLevel.ServiceAndApi; serviceProperties.MinuteMetrics.RetentionDays = 7; serviceProperties.MinuteMetrics.Version = "1.0"; // Set the default service version to be used for anonymous requests. serviceProperties.DefaultServiceVersion = "2015-04-05"; // Set the service properties. await blobClient.SetServicePropertiesAsync(serviceProperties); } catch (StorageException e) { Console.WriteLine(e.Message); Console.ReadLine(); throw; } }
public async Task CloudBlobTestAnalyticsRetentionPoliciesAsync() { CloudBlobClient client = GenerateCloudBlobClient(); 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 MyClassCleanup() { await client.SetServicePropertiesAsync(startProperties); }
public static async Task MyClassCleanup() { CloudBlobClient client = GenerateCloudBlobClient(); await client.SetServicePropertiesAsync(startProperties); }