Have you tried to keep your local environment up to date with the same content as production but the images seem to be broken? This post will walk you through the process of getting the blob assets from production to get the images working locally.
Based on the documentation that Optimizely provides https://docs.developers.optimizely.com/digital-experience-platform/v1.3.0-DXP-for-CMS11-COM13/docs/storage-containers, I will add some extra steps you need to follow to make this easier.
1. Get the Project Id
If you have access to the PAAS Portal, you will be able to get it easily from the URL once you select the Organization:
You can also see the project Id, directly if you go to the API tab:
2. Generate an API Key
In the API tab, click on the “Add API Credentials” button in order to generate the key and secret keys.
Select Production and add a name so you can identify it later:
Once created, you will be able to copy the API key and the API secret values (store them in a safe place)
3. Powershell Scripts
Open Powershell in Administrator mode and install the EpiCloud Powershell module
Install-Module -Name EpiCloud
If you are having issues executing scripts you can set the policy to allow all scripts:
Set-ExecutionPolicy Unrestricted NOTE: this policy will alow the execution of any script. Risks running malicious scripts.
Once you install the module you will be able to execute specific commands
Get-EpiStorageContainer -ProjectId "48530467-XXXX-XXXX-8ded-ab30006f7e8b" -Environment "Production"
You need to provide the ClientKey and the ClientSecret – the ones you generated in the previous step.
The result will show you the name of the containers that are used for production:
We need to focus on the one we have for assets (in this case “media”). Then, we need to generate the SasLink so we can access the container.
Get-EpiStorageContainerSasLink -ProjectId "48530467-XXXX-XXXX-8ded-ab30006f7e8b" ` -Environment "Production" ` -StorageContainer "media" ` -RetentionHours 2
The parameter, -RetentionHours takes a dynamic value for the SAS link expiry; if it is not provided, a default 24 hours is used to generate the link.
Once you execute this script, it will display the link you need to use to download the blobs
Then, you can use the Microsoft Azure Storage Explorer to access the container.
a. Connect to a resource. Select Blob container
b. Then select Shared access signature URL (SAS)
c. Paste the URL generated with the command Get-EpiStorageContainerSasLink
d. From there, you will be able to explore the assets and also download all so you can use them on your local
Finally, you can then copy all the files into the Blobs folder of your local implementation.
The images should be loading fine now. If you don’t see them working, you can execute the scheduled job called “Convert File Blobs” and they will be stored as defined on your configurations.
NOTE: I assume you already got the .bacpac file from the PaasPortal to get the latest content from production.
It can also be exported using the API as documented here