BlobStorage.Advanced.CorsSample C# (CSharp) Method

CorsSample() private static method

Query the Cross-Origin Resource Sharing (CORS) rules for the Queue service
private static CorsSample ( Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient blobClient ) : System.Threading.Tasks.Task
blobClient Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient
return System.Threading.Tasks.Task
        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();
        }