How to deploy App_Data files with Azure cloud service (web role)

user2977157 picture user2977157 · Nov 11, 2013 · Viewed 8.2k times · Source

I have a read-only data file (for IP geolocation) that my web role needs to read. It is currently in the App_Data folder, which is not included in the deployment package for the cloud service. Unlike "web deploy", there is no checkbox for an azure cloud service deployment to include/exclude App_Data.

Is there a reasonable way to get the deployment package to include the App_Data folder/files? Or is using Azure storage for this sort of thing the better way to go? (cost and performance wise)

Am using Visual Studio 2013 and the Azure SDK 2.2

UPDATE: - Found that the App_Data files are actually deployed under /bin/App_Data! So they are there. - Actually ended up moving the file to a storage blob, and copying it to a local storage area on the azure server in the app on startup. This greatly reduced the size of the deployment package, since the static file is not being carried in the package.

Answer

Toolkit picture Toolkit · Jul 10, 2014

If App_Data is not empty, it will be published on Azure website and you can access it via

var folder = Server.MapPath("~/App_Data/");

You can also create folders and write files there

var folder = Server.MapPath("~/somefolder/");
Directory.CreateDirectory(folder);
var path = folder + "file.txt";
File.AppendAllText(path, "some text");