I built an ASP.NET Core api application it is deployed to Azure web api app. In the code, I try at some point to read the contents of a file in content root, interpolating certain place holders for their actual values.
Now on my local system this works just fine cause it is able to get the exact file path of the file but in the cloud, I get an exception with the following message:
Could not find a part of the path...
I get the full file path like so:
Path.Combine(hostingEnvironment.ContentRootPath, "containing directory\filename")
But this fails in the cloud. Are there extras I should know about deploying this or what am I doing wrong with respect to understanding directory structuring in cloud deployment?
N.B I could store this file in an Azure file storage container but I feel it will be too much hassle to read it plus the cost seeing this file will be read quite often.
According to the exception, it indicates that there is no related path in the Azure. If it is possible, we could remote debug Azure Web Apps. Then we could get the file path. After that we could use the Azure kudu(https://yoursite.scm.azurewebsites.net) tool to check whether the path is existing.
If the file path is not existing, we could drag the folder to kudu tool directly or we also could publish the folder with Visual Studio. After that it should work.
We could get more info about Azure Web App sandbox. About Azure website file structure please refer the document