Search code examples
asp.netazureazure-web-app-servicefile-sharing

Accessing file share from Azure Website


We have a web application that consists of three main parts:

  1. Web server running ASP.NET 4.5 Web site;
  2. Database server hosting SQL Server 2012;
  3. Another server hosting some Legacy App used by back office;

Relations between parts are as follows:

  • Web application runs with App Pool Identity set to local user called Foo and consumes database using Entity Framework;

  • Legacy app consumes database and periodically exports data changes in file system as XML files, folder is shared to local user Foo (local user has the same password as on Web Server) using Windows File Share feature;

  • Web application monitors file share for new data and imports all the changes if any;

Now we would like to migrate this application to Azure. Unfortunately we have to use VM for SQL Server because our legacy app database uses File Stream feature which is not available on Azure SQL. Also, we need another VM for legacy app.

Currently I have ended up with the following:

  1. Created a new Virtual Network on Azure;

  2. Created a new Azure Website and connected it to VNET using Point-To-Site VPN connection;

  3. Created 2 VM's for SQL Server and legacy app and connected both to VNET, marked network as private network, disabled firewall;

Everything works fine except one thing - Website is unable to access file share located on Legacy App VM. I have tried to enable sharing to Everyone but to no avail.

So, my question: is it possible to access a file share from an Azure website? If not, what alternatives do I have?

I know that we could spin up another VM for Website and then I would have no issues but I would like to use Azure Website to optimize costs and make use of all Azure goodies.


Solution

  • At the time of writing Azure file service SMB shares are only accessible from VMs, Web- and Worker roles. You can use the storage REST.API or client library to access your files from Azure Websites or on-premise. You can get it from nuget.

    Install-Package WindowsAzure.Storage
    

    I went through the same exercise of moving a web application that used files to Azure. Example of what I did.