approot and sitesroot in Azure
-
29-10-2019 - |
Question
My Azure Web Role needs to be able to delete temporary local files stored in a sub-folder of App_Data. I want to use ICACLS in an Azure elevated startup task to allow IIS to do this as follows:
ICACLS App_Data /grant "IIS_IUSRS":(OI)(CI)F
However, my startup task executes in:
E:\approot\bin
Whereas the root folder where the web application actually ends up in and is executed from seems to be:
E:\sitesroot\0
I’m reluctant to hardcode this path in case Microsoft changes this. Is there a way to get this path from within the startup task or can I rely on this destination?
To test this in an ASPX I add:
Label1.Text = "MapPath: " + Server.MapPath("~/");
Label2.Text = "RoleRoot: " + Environment.GetEnvironmentVariable("RoleRoot");
When I run this on a deployed instance, I get:
MapPath: E:\sitesroot\0\ RoleRoot:
i.e. RoleRoot is empty.
So how can I get the result of Server.MapPath("~/"); in a startup task?
No correct solution