How do I get blobs for an Episerver/Optimizely DXP site?

  • Page Owner: Not Set
  • Last Reviewed: 2021-05-03

How does one pull blobs for a DXP environment?


Answer

There's a Powershell script floating around that purports to do the job (DownloadDxpBlobs.ps1), but it's never worked for me. This is my workflow:

First, you'll need the EpiCloud Powershell module: https://www.powershellgallery.com/packages/EpiCloud

And AzCopy: https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10#download-azcopy

Get the client key and secret for your project / environment. These are usually in 1password, but you can also generate keys in the PAAS portal if none exist.

Next, from the PAAS portal, get the project ID.

If you're not sure what the container name is, you can query all the containers used for a particular project / environment. (Note: there are three possible environments: Integration | Preproduction | Production) From a Powershell terminal, use this command to list the containers:

Get-EpiStorageContainer -ClientKey "..." -ClientSecret "..." -projectId "c146274e-adbb-4a2e-b146-a79b00d33f75" -Environment "Production"

You'll get a response like this:

projectId                            environment storageContainers
---------                            ----------- -----------------
c146274e-adbb-4a2e-b146-a79b00d33f75 Production  { , azure-web-logs, database-backup, mysitemedia}

In this case, you'll see mysitemedia, which is where blobs are stored.

Once you know the container, you can generate a SAS link for the particular container you want to download.

$result = Get-EpiStorageContainerSasLink -ClientKey "..." -ClientSecret "..." -projectId "c146274e-adbb-4a2e-b146-a79b00d33f75" -Environment "Production" -StorageContainer "mysitemedia" -RetentionHours 24

If you dump $result to the terminal, you'll see an sasLink value.

projectId     : c146274e-adbb-4a2e-b146-a79b00d33f75
environment   : Production
containerName : mysitemedia
sasLink       : https://intl01mstr30t1bprod.blob.core.windows.net/mysitemedia?sv=2017-04-17&sr=c&sig=zn8ZQapmLIAMfFo2RoX1NO 
nogXT1AGp1HzYgSOC7X8Y%3D&st=2021-05-03T01%3A33%3A00Z&se=2021-05-04T01%3A33%3A00Z&sp=rl
expiresOn     : 5/4/2021 1:33:00 AM

You can pass the SAS link to AzCopy and copy all the files down:

C:\Path\To\azcopy.exe copy $result.sasLink C:\Path\To\Dest\ --recursive=true

Comments

  • Worked like a charm. Note you may have to change your systems execution policy in order to import the EpiCloud Module. Simply run "Set-ExecutionPolicy RemoteSigned"
  • If you are having trouble seeing all the storage containers you can up you enumeration limit (ex: $FormatEnumerationLimit=20) and then re-run the Get-EpiStorageContainer command