Per Bjurström
Apr 10, 2015
  8695
(3 votes)

Uploading blobs to Azure Storage with PowerShell

When uploading media in EPiServer the binary data are stored in a system called blob providers. By default media are stored on disk in a folder located at <path_to-site>\App_Data\blobs. Moving all those blobs to Azure is just one line of code in the Azure PowerShell console (just make sure the current directory is the blobs-folder):

ls -File -Recurse | Set-AzureStorageBlobContent -Container mycontainer

If you have not used Azure PowerShell before you might want to read the getting started. To store blobs in Azure (you don't need to run the site in Azure to do this) install the EPiServer.Azure package and change blob provider in web.config:

    <blob defaultProvider="azureblobs">
      <providers>
        <add name="azureblobs" type="EPiServer.Azure.Blobs.AzureBlobProvider,EPiServer.Azure"
              connectionStringName="EPiServerAzureBlobs" container="mycontainer"/>
      </providers>
    </blob>

And then add the connection string:

  <connectionStrings>
    <add name="EPiServerAzureBlobs" connectionString="DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=abcdefghij" />
  </connectionStrings>

Screenshot:

Image AzurePowershellCapture.PNG

There is also a scheduled job on NuGet called EPiCode.BlobConverter that supports uploading to any blob provider if you prefer having an actual user interface ;-)

Apr 10, 2015

Comments

Kristina Hedrén
Kristina Hedrén Apr 14, 2015 11:44 AM

Good stuff. How did you authenticate yourself? I used an AzureStorageContext and passed it as a parameter in the given command. Like this:

#log in
Add-AzureAccount
#Create context
$myContext = New-AzureStorageContext -StorageAccountName $MyName -StorageAccountKey $MyKey
#get files
ls -File -Recurse | Set-AzureStorageBlobContent -Container $mycontainer -Context $myContext

Worked like a charm.

Apr 14, 2015 01:40 PM

Great. If I remember correctly I used this command:

Set-AzureSubscription -SubscriptionName "MySubscription" -CurrentStorageAccountName "MyStorageAccount"

Apr 14, 2015 01:42 PM

And before that Import-AzurePublishSettingsFile to get the credentials..

valdis
valdis Nov 2, 2015 10:13 PM

Great success! Thanks Per. Old post - but helpful!

Please login to comment.
Latest blogs
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024