Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Per Bjurström
Apr 10, 2015
  8530
(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
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog