15 september 2024
Azure Files and IIS: How to Serve Files to Users Through an SMB Share
In web applications, file-handling functionality is very common: upload a file, store it somewhere, and then serve it back to the user via a link. These files might be PDFs, images, CSVs, or other documents that the application does not generate on the fly but simply stores and later displays in the browser. The most obvious solution is to place those files on the local disk of the machine where IIS is installed. For a small solution, that can work perfectly well. But as soon as the system becomes a bit more serious, reasonable questions start to arise: how reliable is it, really, to keep user files on the disk of a specific host? If that host gets damaged, recreated, migrated, or simply maintained in an unexpected way, the file layer quickly becomes a problem of its own. At the same time, you do not always want to move straight to Blob Storage and completely change the application’s file-handling model. Sometimes it is more convenient to preserve the familiar Windows and IIS approach: folders, UNC paths, a file system, and standard file delivery through the web server. In that scenario, Azure Files mounted over SMB is a good compromise. Below, let’s look at this approach as an engineering task: how to connect an Azure File Share to Windows Server, how to configure IIS, why permissions almost always become an issue here, and how to make the whole setup actually work.