Git Product home page Git Product logo

umbracofilesystemproviders.azure's Introduction

UmbracoFileSystemProviders.Azure v2+

This version is for Umbraco v8 only. For the v1 package for Umbraco v7 please visit the develop branch

Image Alt

Build status

An Azure Blob Storage IFileSystem provider for Umbraco Used to offload static files in the media section to the cloud.

This package allows the storage and retrieval of media items using Azure Blob Storage while retaining the relative paths to the files expected in the back office.

v2 requires Umbraco v8.1.0+

Installation

Both NuGet and Umbraco packages are available. If you use NuGet but would like the benefit of the Umbraco configuration wizard you can install the Umbraco package first, use the wizard, then install the NuGet package, the configuration will be maintained.

From v2.0.0-alpha3 onwards this package was split into 2 NuGet packages and an additional one was added to support Umbraco Forms. When using NuGet install the UmbracoFileSystemProviders.Azure.Media package to swap Media storage to Blobs.

If upgrading from v2.0.0-alpha1 or v2.0.0-alpha2 to v2.0.0-alpha3 you will need to install UmbracoFileSystemProviders.Azure.Media

v3 is v2 refactored to use the Azure SDK v12

NuGet Packages Version
Release Core NuGet download
Release Media NuGet download
Release Forms NuGet download
Bleeding edge Core MyGet download
Bleeding edge Media MyGet download
Bleeding edge Forms MyGet download
Umbraco Packages
Release Our Umbraco project page
Bleeding edge AppVeyor Artifacts

Manual build

If you prefer, you can compile UmbracoFileSystemProviders.Azure yourself, you'll need:

  • Visual Studio 2019 (or above)

To clone it locally click the "Clone in Windows" button above or run the following git commands.

git clone https://github.com/umbraco-community/UmbracoFileSystemProviders.Azure
cd UmbracoFileSystemProviders.Azure
.\build.cmd

In the interim code reviews and pull requests would be most welcome!

Media

Configuration via Web.Config

In Web.config create the new application keys

<add key="AzureBlobFileSystem.ConnectionString:media" value="DefaultEndpointsProtocol=https;AccountName=[myAccountName];AccountKey=[myAccountKey]" />
<add key="AzureBlobFileSystem.ContainerName:media" value="media" />
<add key="AzureBlobFileSystem.RootUrl:media" value="https://[myAccountName].blob.core.windows.net/" />
<add key="AzureBlobFileSystem.MaxDays:media" value="365" />
<add key="AzureBlobFileSystem.UseDefaultRoute:media" value="true" />
<add key="AzureBlobFileSystem.UsePrivateContainer:media" value="false" />

Additionally the provider can be further configured with the following application setting in the web.config.

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <!--Disables the built in Virtual Path Provider which allows for relative paths-->
    <add key="AzureBlobFileSystem.DisableVirtualPathProvider" value="true" />
    <!--
      Enables the development mode for testing. Addition changes to the FileSystemProviders.config are also required
    -->
    <add key="AzureBlobFileSystem.UseStorageEmulator" value="true" />
  </appSettings>
</configuration>

Configuration using Azure Key Vault

For Azure Key Vault only the key values in the Web.config should use '-', rather than a '.' or ':' as shown below

<add key="AzureBlobFileSystem-ConnectionString-media" value="DefaultEndpointsProtocol=https;AccountName=[myAccountName];AccountKey=[myAccountKey]" />
<add key="AzureBlobFileSystem-ContainerName-media" value="media" />
<add key="AzureBlobFileSystem-RootUrl-media" value="https://[myAccountName].blob.core.windows.net/" />
<add key="AzureBlobFileSystem-MaxDays-media" value="365" />
<add key="AzureBlobFileSystem-UseDefaultRoute-media" value="true" />
<add key="AzureBlobFileSystem-UsePrivateContainer-media" value="false" />

Virtual Path Provider

By default the plugin will serve files transparently from your domain or serve media directly from Azure. This is made possible by using a custom Virtual Path Provider included and automatically initialised upon application startup. This can be disabled by adding the configuration setting noted above.

Note: Virtual Path Providers may affect performance/caching depending on your setup as the process differs from IIS's unmanaged handler. Virtual files sent via the provider though are correctly cached in the browser so this shouldn't be an issue. VPP providers also don't work with Precompiled sites or when used in a virtual directory/application.

The following configuration is required in your web.config to enable static file mapping in IIS Express.

<?xml version="1.0"?>
  <configuration>
    <location path="Media">
      <system.webServer>
        <handlers>
          <remove name="StaticFileHandler" />
          <add name="StaticFileHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" />
        </handlers>
      </system.webServer>
    </location>
  </configuration>

Also add this configuration to the web.config inside the Media folder

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<system.webServer>
		<handlers>
			<clear />
			<add name="StaticFileHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" />
			<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
		</handlers>
	</system.webServer>
</configuration>

Combining with ImageProcessor

ImageProcessor.Web contains a IImageService called CloudImageService, to enable that service and pull images directly from the cloud replace the CloudImageServicesetting with the following:

<?xml version="1.0"?>
<security>
  <services>
    <service name="LocalFileImageService" type="ImageProcessor.Web.Services.LocalFileImageService, ImageProcessor.Web"/>
    <service prefix="media/" name="CloudImageService" type="ImageProcessor.Web.Services.CloudImageService, ImageProcessor.Web">
      <settings>
        <setting key="Container" value="media"/>
        <setting key="MaxBytes" value="8194304"/>
        <setting key="Timeout" value="30000"/>
        <setting key="Host" value="https://[myAccountName].blob.core.windows.net/"/>
      </settings>
    </service>
  </services>  
</security>

Note The CloudImageServiceis not compatible with the FileSystemProvider when using private storage. You can instead use the AzureImageService which is included with the AzureBlobCache package

Optionally install the AzureBlobCache plugin to get the most out of the package.

Umbraco Forms

Currently this package is available only via NuGet

Install-Package UmbracoFileSystemProviders.Azure.Forms

Configuration via Web.Config

In Web.config update the new application keys with the required credentials

<add key="AzureBlobFileSystem.ContainerName:forms" value="forms-data" />
<add key="AzureBlobFileSystem.RootUrl:forms" value="https://[myAccountName].blob.core.windows.net/" />
<add key="AzureBlobFileSystem.ConnectionString:forms" value="DefaultEndpointsProtocol=https;AccountName=[myAccountName];AccountKey=[myAccountKey]" />
<add key="AzureBlobFileSystem.UsePrivateContainer:forms" value="false" />

Warning

The Azure Blob container cannot be called forms as this will give unexpected behaviour, and we recommend you call it form-data or similar.

Authors

  • James Jackson-South
  • Dirk Seefeld
  • Lars-Erik Aabech
  • Jeavon Leopold

Thanks

  • Elijah Glover for writing the Umbraco S3 Provider which provided inspiration and some snazzy unit testing code for this project.

umbracofilesystemproviders.azure's People

Contributors

jeavon avatar jimbobsquarepants avatar idseefeld avatar callumbwhyte avatar rsoeteman avatar nul800sebastiaan avatar tomfulton avatar ptrstpp950 avatar sjones-marathon avatar alantsai avatar cyberprune avatar lars-erik avatar shazwazza avatar stevetemple avatar walalm avatar dependabot[bot] avatar philo avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.