3

I do have an ASP.NET Core 5 Web API project which is currently hosted as an Azure Web App on a Windows App Service plan. Since I have a couple of gigabytes of storage associated with the App Service plan, I want to use 10 GB for an image cache where I store images generated from the API.

Here is some context:

  • I don't want to use Azure Storage / Blob Storage for this to avoid unnecessary traffic costs and delays. Some images are generated from multiple layers of other images (let's call them intermediate images) and I cache everything.
  • My caching solution works fine locally, but currently not on Azure.
  • I want to use 'Remove additional files at destination' when publishing a new version of my API.
  • The cache will be cleared/invalidated via an API call, not on deployment or app restart.

As I've said, the caching works fine if I run at locally on IIS Express. As far as I know, the Windows App Service plan uses Kestrel for hosting. I'm looking for a storage path within the Azure Web App, where I can create and delete directories + create/read/delete files.

Since the App Service Plan is B1, the App Service plan is running on a dedicated Azure VM, according to the docs: https://learn.microsoft.com/en-us/azure/app-service/overview-hosting-plans

From https://learn.microsoft.com/en-us/azure/app-service/operating-system-functionality, I've learned that there is a C drive and a D drive as well.

From my web app, I can select Development Tools -> Advances Tools -> Go to see Kudu. When I click on Environment in Kudu, I can see some absolute paths that I've tried to write to without success. I've also tried to access

  • Environment.GetEnvironmentVariable("HOME")
  • IWebHostEnvironment.WebRootPath
  • IWebHostEnvironment.ContentRootPath
  • "D:\home\site\wwwroot"
  • "D:\home\"

without success as well. I also tried to add a virtual directory (since I want to store images in another directory to be able to use the 'remove additional files on destination' option). I also connected via FTP to /site/wwwroot/ where I can see my deployed application.

In the past, I was able to read files from a virtual directory from an ASP.NET Webforms application, but with this ASP.NET Core 5 API project, I didn't have any success mapping relative paths to absolute paths.

My main question is: What absolute path to I need to use in my API project to have create/delete directory permissions and create/read/delete file permission into my Azure Web App?

1 Answer 1

2

Okay, I've figured it out. I had some fatal errors when starting the application. It seems that they were related to ApplicationInsights. I removed it completly from the Azure Web Portal and now everything works.

The following path works as a base path D:\\home\\

Sign up to request clarification or add additional context in comments.

1 Comment

Shout out you man thank you so much true life saver. Had to migrate an IIS app to Azure on a project I didn't create and they used local temp file storage for PDF generation before using it to be sent out for download. Had to find some kind of path to make it work and D:\home\ was perfect. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.