[英]Need to access a directory from .net website hosted on Azure
I have an Asp.net website hosted on Azure. 我在Azure上托管了一个Asp.net网站。 It has an upload excel file functionality so a Fileupload control is in play.
它具有上载excel文件功能,因此可以使用Fileupload控件。
string fileToSave = ConfigurationManager.AppSettings["DirectoryLocation"] + FileUpload.FileName;
FileUpload.PostedFile.SaveAs(fileToSave);
This works fine in traditional IIS servers but in Azure I am not sure what path to give in for "ConfigurationManager.AppSettings["DirectoryLocation"]". 在传统的IIS服务器中,此方法工作正常,但在Azure中,我不确定为“ ConfigurationManager.AppSettings [“ DirectoryLocation”]“指定的路径。
I have tried some shared location but looks like it cannot access those. 我尝试了一些共享位置,但看起来无法访问这些位置。
Please give me some direction. 请给我一些方向。
In contrast to a web application that is hosted on a local IIS your application can run on several instances in Azure that you do not have control over. 与本地IIS上托管的Web应用程序相比,您的应用程序可以在不受控制的Azure中的多个实例上运行。 It even can be moved to another server under certain circumstances.
在某些情况下,甚至可以将其移动到另一台服务器。 So using a local file system folder is not an option.
因此,使用本地文件系统文件夹不是一种选择。 Instead, you have to use a store that you can access from all the instances.
相反,您必须使用可以从所有实例访问的存储。
Have a look at the following overview of Azure Storage under this link . 在此链接下查看以下Azure存储概述。 Typically, you would store files in a Blob or a File Storage.
通常,您会将文件存储在Blob或文件存储中。 On this site, you can also find some samples on how to access the storage from the cloud (and later on from an on-premise application that processes the data).
在此站点上,您还可以找到一些有关如何从云中访问存储的示例(以及稍后从处理数据的本地应用程序中访问示例)。
This code should work but I would recommend you to store files in blob storage. 该代码应该可以工作,但是我建议您将文件存储在Blob存储中。 See https://azure.microsoft.com/fr-fr/documentation/articles/storage-dotnet-how-to-use-blobs/
请参阅https://azure.microsoft.com/fr-fr/documentation/articles/storage-dotnet-how-to-use-blobs/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.