/// <summary> /// Query the Cross-Origin Resource Sharing (CORS) rules for the File service /// </summary> /// <param name="fileClient"></param> private static async Task CorsSample(CloudFileClient fileClient) { Console.WriteLine(); // Get service properties Console.WriteLine("Get service properties"); FileServiceProperties originalProperties = await fileClient.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 }; FileServiceProperties serviceProperties = await fileClient.GetServicePropertiesAsync(); serviceProperties.Cors.CorsRules.Add(corsRule); await fileClient.SetServicePropertiesAsync(serviceProperties); } finally { // Revert back to original service properties Console.WriteLine("Revert back to original service properties"); await fileClient.SetServicePropertiesAsync(originalProperties); } Console.WriteLine(); }