Skip to main content

Optimizely

Uploading blobs to Optimizely DXP via PowerShell

Data Transfer Cloud Computing Technology Concept. There Is A Large Prominent Cloud Icon In The Center With Internal Connections. And Small Icon On Abstract World Map Polygon With Dark Blue Background.
We had a client moving from an On-Prem v11 Optimizely instance to DXP v12 and we had a lot of blobs (over 40 GB) needing uploading to DXP as a part of the conversion.
 
This was my first experience doing both a version and environment upgrade and I leaned heavily on Optimizely support to help me get it right. Along the way, I wrote down each step so that I could reference it for any future projects that were doing the same. Perhaps someone else will be in the same spot and can benefit from this tutorial as well.
 
Blobs and the database can now be uploaded to DXP directly in PowerShell.
 

To upload blobs to DXP via PowerShell

  1. Get the location of the blobs
    1. Find the folder on your machine where the blobs are located and unzipped.
    2. Write down that folder path (ie “C:\source\MyProject\MyProject.Web\App_Data\blobs”).
    3. (Important) Make sure the path ends with “\*” so that you copy only the contents of the blob folder and not the folder itself (ie “C:\source\MyProject\MyProject.Web\App_Data\blobs\*”).
    4. This full path will be referred to later as $BLOB_LOCATION.
  2. Get AzCopy from Microsoft
    1. Download AzCopy from Microsoft (https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10#download-azcopy).
    2. Extract the executable to a folder on your machine.
    3. Traverse the extracted files to find the executable, “azcopy.exe”.
    4. Write down the location of the executable (ie “%USERPROFILE%\Downloads\azcopy_windows_amd64_10.23.0\azcopy_windows_amd64_10.23.0\” or “C:\Users\Me\Downloads\azcopy_windows_amd64_10.23.0\azcopy_windows_amd64_10.23.0\”).
  3. Ask Opti (managed services?) to provide a temporary SAS URL/authentication. This will be referred to later as $SAS_URL.
    1. Take note of the container name found in the SAS URL (“https://*.blob.core.windows.net/MYCONTAINERNAME”).
  4. Populate the azcopy command using values from steps 1.4 & 3.
    azcopy copy "$BLOB_LOCATION" "$SAS_URL" --recursive=true

    Example:

    azcopy copy "C:\source\MyProject\MyProject.Web\App_Data\blobs\*" "https://mysite.blob.core.windows.net/MYCONTAINERNAME?sp..." --recursive=true
  5. Open a PowerShell window and navigate to the folder from step 2.4.
  6. Paste the azcopy command from step 4 and run it.
  7. Make sure you have the following in your Startup.cs
public void ConfigureServices(IServiceCollection services)
{
    services.AddAzureBlobProvider(o =>
    {
        o.ContainerName = "MYCONTAINERNAME";
    });
    services.AddAzureEventProvider();
}

If this has been helpful, check out my two-part series on setting up Local HTTPS for Optimizely, IIS, and Kestrel using certificates.

Thoughts on “Uploading blobs to Optimizely DXP via PowerShell”

  1. Anders Wahlqvist

    Hi Nick!
    Thank you for this blog post! I just wanted to mention that you can perform these steps without even reaching out to support. You can get the SAS-link mentioned in step 3 through the deployment API.

    To import a DB see:
    https://docs.developers.optimizely.com/digital-experience-platform/docs/export-database#import-database

    To upload blobs (use the -Writable switch):
    https://docs.developers.optimizely.com/digital-experience-platform/docs/storage-containers#get-epistoragecontainersaslink

    Hopefully makes this process even smoother!

  2. Nick Hamlin Post author

    Thanks Tomas!
    I found a solution for a different client that used a different container name, which is why I thought it might be dynamic. However, for this client Opti had created the storage container as ‘mysitemedia’ as you mentioned. The documentation online is confusing because I was using this page in the CMS 12 developer docs to figure out how to deploy blobs: https://docs.developers.optimizely.com/content-management-system/docs/deploying-to-azure-webapps. In this page it says each account creates their own Blob Storage Account and Service Bus, but that’s handled by Optimizely support.

    Thanks for this information. It’s a helpful addition for sure.

  3. Nick Hamlin Post author

    Hi Anders,
    Thanks for these links. They would have been helpful, and hopefully are helpful to anyone reading this post.

    Cheers!
    Nick

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.

Nick Hamlin, Lead Technical Consultant

Nick Hamlin is a Lead Technical Consultant with Perficient. He has been programming for over 20 years, focusing on Optimizely CMS and Commerce since 2018. In his free time, he enjoys playing bar trivia, writing music, cooking, and finding cheap airfare to travel the world. Nick is fluent in English & Spanish and has studied French, Portuguese, and German.

More from this Author

Categories
Follow Us