更新:
在回答此问题时,Azure门户没有此功能。现在按此处概述进行操作。下面概述了添加UI之前执行此操作的方法。
如何在Portal的Azure BLOB存储中配置CORS?
如果愿意,可以始终以编程方式设置BORS存储的CORS规则。如果您使用的是.Net Storage
Client库,请从存储团队中查看此博客文章:http :
//blogs.msdn.com/b/windowsazurestorage/archive/2014/02/03/windows-azure-
storage-introducing-
cors.aspx。用于从该博客文章中设置CORS设置的代码:
private static void InitializeCors(){ // CORS should be enabled once at service startup // Given a BlobClient, download the current Service Properties ServiceProperties blobServiceProperties = BlobClient.GetServiceProperties(); ServiceProperties tableServiceProperties = TableClient.GetServiceProperties(); // Enable and Configure CORS ConfigureCors(blobServiceProperties); ConfigureCors(tableServiceProperties); // Commit the CORS changes into the Service Properties BlobClient.SetServiceProperties(blobServiceProperties); TableClient.SetServiceProperties(tableServiceProperties);}private static void ConfigureCors(ServiceProperties serviceProperties){ serviceProperties.Cors = new CorsProperties(); serviceProperties.Cors.CorsRules.Add(new CorsRule() { AllowedHeaders = new List<string>() { "*" }, AllowedMethods = CorsHttpMethods.Put | CorsHttpMethods.Get | CorsHttpMethods.Head | CorsHttpMethods.Post, AllowedOrigins = new List<string>() { "*" }, ExposedHeaders = new List<string>() { "*" }, MaxAgeInSeconds = 1800 // 30 minutes });}如果您正在寻找执行此操作的工具,则一些存储浏览器支持配置CORS-Azure存储资源管理器,Cerebrata Azure ManagementStudio,Cloud Portam(公开-我正在构建Cloud Portam实用程序)。
正确配置CORS之后,您可以使用Rory的答案中提到的代码从blob存储中下载文件。正如Rory所说,您不必在客户端做任何特殊的事情。



