why using (var fileStream = new FileStream(myPath, FileMode.Create)) not working when app is deployed to Azure App Service?

maytals2001 0 Reputation points
2024-03-11T09:24:14.4033333+00:00

I need help. I am new here I don't even know the proper way to ask

I have an app that saves documents to the wwwroot folder. Locally it works fine, but when deployed to the app service it breaks when it gets to the stament : using (var fileStream = new FileStream(myPath, FileMode.Create))

It says Exception thrown: 'System.IO.DirectoryNotFoundException' in System.Private.CoreLib.dll

Developer technologies | ASP.NET | ASP.NET Core
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,971 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,086 Reputation points Volunteer Moderator
    2024-03-11T15:09:39.9133333+00:00

    Azure app service is a webfarm. It does not make sense to write to an upload file to a local folder, as it will only be available from the physical server that uploaded it. You need to use shared storage like azure blob storage.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.