Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 812
user2977157 Avatar asked Nov 11 '13 06:11

user2977157


People also ask

Can we deploy jar file in Azure App Service?

You can deploy your WAR, JAR, or EAR package to App Service to run your Java web app using the Azure CLI, PowerShell, or the Kudu publish API.

How do you deploy a WAR file on Azure app services?

You can deploy your WAR package to Azure App Service to run your Java web app using the Azure CLI, PowerShell, or the Kudu Publish API. Note: It is not recommended of deploying WAR / JAR / EAR packages using FTP or WebDeploy .

What is the recommended way to deploy a custom code solution in Azure?

Navigate to your app in the Azure portal and select Deployment Center under Deployment. Follow the instructions to select your repository and branch. This will configure a DevOps build and release pipeline to automatically build, tag, and deploy your container when new commits are pushed to your selected branch.


2 Answers

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");
like image 116
Toolkit Avatar answered Sep 19 '22 03:09

Toolkit


I experienced the same issue. after deploying my service, I run a recursive directory search on the local directory on the Azure server (string appRoot = Environment.CurrentDirectory;) and found that the stored files are under E:\\approot\\App_Data\\<file name> then I used the following code appRoot = Path.Combine(appRoot + @"\", @"App_Data\<file name>t");

like image 31
user3409225 Avatar answered Sep 19 '22 03:09

user3409225