Umbraco setup with media folder on an Azure File Share

We had a client who is moving their legacy Umbraco 4 and 6 sites to Azure VMs, and wanted to use Azure File Share for the shared media folder, rather than the recommended DFS setup.

After some trial and error we got this working (starting from a vanilla Umbraco site), by making sure the following:

  • Create a local Windows user account with the same credentials as the Azure File Share user and password
  • Set the IIS app pool user to the Azure File Store local user  – So Umbraco could access/write to the media folder
  • Set website > authentication > anonymous auth – to use App pool user (not IUSR) – So I could browse to files stored in the media folder
  • Create an IIS ‘Application’ for “media”  (not a virtual directory) – so I can stop the Umbraco web.config from applying to the media folder (see error below)
    • The path should be set to the Azure File Share folder e.g. \\myfilestorage.file.core.windows.net\myfileshare\media (you should map a network drive and create a ‘media’ folder first)
  • Update the web.config and wrap all the Umbraco stuff with <location path=”.” inheritInChildApplications=”false”></location> – to stop the Umbraco web.config from applying to the media folder (see error below)
    • The <configSections> and <runtime> sections must be kept outside of the <location> section.

We have uploaded a bunch of media without error and performed a stress test on the loading of media item via the load balanced front end, without any issues.

We have also checked this works with Umbraco 7 although when we upgrade to this we intend to use Blob storage instead. The Umbraco 7 default web.config includes some <location> sections which must also be moved outside the new <location> tag, and I had to also remove the legacy <httpModules> section to stop some wierd errors…

If you don’t do the last two steps, then it will work in Umbraco but when browsing to a media item you will see this error:

If you forget to set the site authentication to use App Pool Identity, then you will instead get a wierd error code 414 to do with the request URL being too long!

 

2 thoughts on “Umbraco setup with media folder on an Azure File Share

  1. Hi Andrew, thanks for your blog post. Very good solution and relevant.

    I did have a question though…

    We have an Umbraco website with an image library. The images are restricted to different Umbraco member groups. So we simply add member permissions to each image for them to view/download an image.

    Currently, all images are added to the default ~/media/ folder.

    Our client wants to store the “media” folder on their own internal server, separate from the rest of the the site, which sits on our server. If we did this, does this then mean that the images would no longer be protected? I.e. someone with a direct image location URL can access the images whether they are logged in or not?

    Any feedback here would be helpful.

    Thanks in advance,
    Robert.

  2. Hi Robert

    Thanks for the comment. I think you will be fine if you will put the share on another machine on the same network. Then you can set the media folder up as a virtual directory pointing to the file share (should not need to make it an application). This way the root web config should not need to be changed, and Umbraco should still handle media requests, applying your permission checks.

    I think you do need to use the same domain/user/password on both machines in order to authenticate the file share for the virtual directory.

    We have done this a few times and it is a bit fiddly but works once set up. Reply if you get stuck I can dig out setup notes from one of our projects.

    The setup is similar to https://our.umbraco.org/documentation/getting-started/setup/server-setup/load-balancing/files-shared but we have only put the media folder as a share, keep the rest of umbraco local.

    Thanks
    Andy

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.