Hi @Adwait Naik Greetings! Thank you for posting the question here.I have tried the below setting in my .csproj
file and could push the sub folders to Azure function.
<None Update="Content\**\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
Please note that the output directory is used during development, while the publish directory is used when the project is published.
Once I deployed the code, I could see the folders under the Files section in VS Code. Please find the below image for reference.
The folder directories are added under the Azure function C:\home\site\wwwroot
directory. In the above example, to access welcome.html file, you can access it through the path C:\home\site\wwwroot\Content\Files\welcome.html
Here is a snippet of the code I have tested to see if the files can be accessed.
public IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req)
{
_logger.LogInformation("C# HTTP trigger function processed a request.");
string baseFolderPath = @"C:\home\site\wwwroot\Content";
string fileRelativePath = @"Files\welcome.html";
string fullPath = Path.Combine(baseFolderPath, fileRelativePath);
string html = File.ReadAllText(fullPath);
return new ContentResult
{
Content = html,
ContentType = "text/html",
StatusCode = 200
};
}
Hope this helps! Please let us know if you have any additional questions or issues.
If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.