Azure sharing photos from IIS VMs using a file sha

2020-03-30 05:49发布

问题:

How can I create a file share that can be shared across web servers running in a VM to directly access the blob storage in Azure?

I am moving an existing n-tier website application written in .net 1.1 to Azure Virtual Machines.

This is a legacy application, I want to move it to azure in its current form then slowly make changes to code to take advantages of the cloud type services at a later time.

The application is currently split across 4 servers:

1 x SQL Database Server

2 x IIS Web server for application (load balanced via round robin dns)

1 x IIS Web Server for photos (hosts millions of user uploaded photos)

The photo server is a monster machine with a RAID 10 array of 12 HDD.

Users can upload photos which are transferred via the web servers to the photo server using a simple file share. Eg:

\\PhotoServer1\UserData\Photos\

The file share is mounted as the Z:\ drive on the 2 web servers and they have no problem reading and writing files to the photo server via the share.

The photo server also acts as an IIS web server and is used to host the files. Eg:

http://photos.mysite.com/userdata/photos/234/234photo.jpeg

I can easily move the SQL server and the IIS web servers to Virtual Machines on Azure.

But I am struggling to understand how I can implement the file/web photo server in its current form.

I want to setup a file share on the web servers and then read/write/delete photos via the web server VMs.

I could simply setup another VM for the file/web server but it is a busy machine and I would need to create a RAID array of drives which seems pointless as the Azure storage already does this on its own accord.

I cant get my head around the blob storage, I know its not a Hard Drive, but it would be handy to treat it as such for legacy applications and especially share it between servers.

Questions:

  1. How can I create a file share that can be shared across web servers running in a VM to directly access the blob storage in Azure?

  2. If I do store everything in blob storage, do I still need an IIS server to host the files, if so would this also be mounted to IIS via a fileshare?

回答1:

Azure Storage has two potential services you can consider to solve your problem – Azure Blobs and Azure Files.  As David mentions in his answer, the Azure File Service is designed to look exactly like a standard file share, as long as you access it from a VM in the cloud.  You can mount the share in one or more VM’s and access it just as you would a local file share. The link that David posted is a good starting place, http://blogs.msdn.com/b/windowsazurestorage/archive/2014/05/12/introducing-microsoft-azure-file-service.aspx, also see here: http://blogs.msdn.com/b/windowsazurestorage/archive/2014/05/27/persisting-connections-to-microsoft-azure-files.aspx.

Blob storage is a bit like a file system, but stored in the cloud and accessed through REST APIs.  For a code/example-based overview of blob storage, I recommend the code samples under http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-blobs/.  If you make use of blob storage, you could have clients access the blobs directly, depending on your authentication needs.  Blob storage supports three types of authentication – Anonymous (anyone can access), Shared Key (must have your storage account key to access, account key gives complete access to everything in the storage account), and SAS (Shared Access Signature, gives access at the blob or container level).  SAS is often a good choice, and remove the need to have a server hosting the files, although clients do need a way to access the SAS token.  See http://msdn.microsoft.com/en-us/library/azure/hh225339.aspx for an authentication overview.

Note that the blob and file services are separate, you can't access data in one from the other.



回答2:

There are several ways to implement a file share, including hosting it on a VM as you suggested. However, that wouldn't give you a durable solution since the file share would go offline if the VM went offline.

Azure now offers File Service (still in Preview), which lets you set up SMB 2.1 (backed by blob storage). This would allow you to run net use to mount the share as a drive letter, and off you go.

More information may be found here.