Azure App service not allowing to Edit the files present in wwwroot folder: "Access to the path 'D:\home\site\wwwroot\wwwroot/templates/abc.pdf' is denied"

Saleem Baig 1 Reputation point
2021-02-03T13:42:23.553+00:00

I am facing one weird issue.
I have created one .net core application that overwrites the pdf file available in root location of application; and this is working fine locally.
but when i publish on Azure App service and run, use to get error

Access to the path 'D:\home\site\wwwroot\wwwroot\templates\abc.pptx' is denied.

Here is the code, i am using in Azure App Service

var masterFile = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\templates\","MasterTemplate.pptx");
var dummyFile = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\templates\", "abc.pptx");

System.IO.File.Copy(masterFile , dummyFile, true);

=====================
Please suggest if you know any solution around...

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,852 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 15,696 Reputation points
    2021-02-10T03:31:46.897+00:00

    Hi @Saleem Baig ,

    Thanks for your patience! Based on this SO thread you can try changing this

    App Setting Key

    WEBSITE_RUN_FROM_PACKAGE = 1 to 0  
    

    "This setting makes wwwroot as a read-only file system. With Run From Package, this is strictly enforced as the wwwroot folder becomes read-only"

    If you are still facing this issue please reach out to us at azcommunity@microsoft.com with the subject "ATTN: Grace" and in the body of the email include your Azure Subscription ID.
    -Grace

    2 people found this answer helpful.