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>
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 ;-)
Good stuff. How did you authenticate yourself? I used an AzureStorageContext and passed it as a parameter in the given command. Like this:
$myContext = New-AzureStorageContext -StorageAccountName $MyName -StorageAccountKey $MyKey
ls -File -Recurse | Set-AzureStorageBlobContent -Container $mycontainer -Context $myContext
Worked like a charm.
Great. If I remember correctly I used this command:
Set-AzureSubscription -SubscriptionName "MySubscription" -CurrentStorageAccountName "MyStorageAccount"
And before that Import-AzurePublishSettingsFile to get the credentials..
Great success! Thanks Per. Old post - but helpful!