1
votes

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://docs.microsoft.com/en-us/azure/app-service/overview-hosting-plans

From https://docs.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

1 Answers

0
votes

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\\