How to Save Files Temporarily in Azure Functions?
Asked by
SkyBlueNinja37
Hey everyone, I'm facing a challenge with saving files to the Azure file system. We have a use case where we need to save files for a short time and then delete them. Locally, everything works well, and files are saved in the Files folder. However, once I deploy to Azure, I get an error saying "Invalid path, path not found." Is there a way to save files in the Azure file system? Thanks in advance!
Answers
You can indeed mount Azure Files, but I would suggest using temporary Blob Storage like some others mentioned. Itโs a more robust solution for what youโre trying to achieve.
Reply to this answer
You need to make sure you're getting a temporary file path from the system. If youโre using .NET, you can use System.IO.Path.GetTempPath(). Keep in mind that local storage in Azure Functions is temporary, so files might not persist between executions. But for your use case, a durable location like Blob Storage for input/output is essential.
Reply to this answer
It sounds like you might want to rethink that approach. Generally, cloud environments like Azure arenโt meant for temporary file storage like a traditional server would be. Itโs better to use Blob Storage for saving your files instead. Trust me, itโs the way to go!
StorageWizard42: Absolutely! Setting up Blob Storage is really straightforward and perfect for what you need.
TechSavvy14: Exactly! Blob Storage is ideal for short-term file storage. You can just upload and delete when you're done.
Reply to this answer
Add your answer
Answers are reviewed before publication.
HappyDev72: Thanks for the tip! We tried using the temp path, and it works like a charm!