private static void UpdateServiceProperties(CloudBlobClient blobClient, List <string> origins, List <string> headers, List <string> methods) { ServiceProperties props = blobClient.GetServiceProperties(); Trace.Write(props.Cors.CorsRules.ToString()); if (!ContainsOrigin(props.Cors.CorsRules, origins)) { props.Cors.CorsRules.Add( new CorsRule { AllowedOrigins = origins, AllowedHeaders = headers, AllowedMethods = ExpandCorsHttpMethods(methods), MaxAgeInSeconds = 1800 // 30 minutes }); blobClient.SetServiceProperties(props); } }
static void Main(string[] args) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["mafs:StorageConnectionString"]); CloudBlobClient client = storageAccount.CreateCloudBlobClient(); ServiceProperties serviceProperties = client.GetServiceProperties(); CorsProperties corsSettings = serviceProperties.Cors; AddRule(corsSettings); //corsSettings.CorsRules.RemoveAt(0); //serviceProperties.DefaultServiceVersion = "2015-07-08"; client.SetServiceProperties(serviceProperties); Console.WriteLine("DefaultServiceVersion : " + serviceProperties.DefaultServiceVersion); DisplayCorsSettings(corsSettings); Console.ReadKey(); }