By default, we can store Blobs in SQL Database. Earlier we had the option to store Blobs in the file system. From, Sitecore 9.3 we have the Blob Storage concept. Blob Storage concepts give us freedom to configure storage providers as we like. Yes, So we can configure Sitecore to store Blobs anywhere we like :).
We can install the Sitecore Azure Blob Storage module to configure Sitecore to store Blobs in Azure Storage. Do you need to Store Blobs somewhere else?. May be in Google Cloud Storage or in AWS Storage. In that case, we can implement our own storage provider implementing Sitecore.Framework.Data.Blobs.Abstraction.
Let’s take a look at how we can configure the Sitecore Azure Blob Storage module in on-prem Sitecore 9.3 instance. Please refer the Sitecore doc for installing Sitecore 9.3
1.Download Sitecore Azure Blob Storage module from here
2. Create an Azure Storage Account. Refer Microsoft docs for more information
3. Create a container
4. Copy the Storage connection string. Refer Microsoft docs
5. Use MsDeploy to install Sitecore Azure Blob Storage WDP.
"<FolderPathOfMsDeploy>\msdeploy.exe" -verb:sync -source:package="<FilePathOfWDP>" -dest:auto="<RootUrlOfSitecoreInstance>" -setParam:"IIS Web Application Name"="<IISWebAppName>" -setParam:"AzureStorageConnectionString"="<AzureStorageConnectionString>" -setParam:"AzureStorageContainerName"="<AzureStorageBlobContainerName>" -setParam:"DefaultProvider"="azure" -enableRule:DoNotDeleteRule -verbose |
Parameters:
- FilePathOfWDP: File path to Azure Blob Storage WDP
- RootUrlOfSitecoreInstance: Url of Sitecore instance . In my case ” https://sc93xpcm/ ” .
- IISWebAppName: IIS Web App Name. ex: “sc93xpCM”
- AzureStorageConnectionString: Azure storage connection string we copied from the previous step no 4.
- AzureStorageContainerName: Azure Storage container name
Above msdeploy cmd install the module in SC instance.
We have to do extra step on on-premise installation. We need to update Connectionstring.config. We can do it manually or using XDT transformation.
- Manual Step.
Add below node addingAzure Storage connection string into connectionstring.config.
<add name=”azureblob” connectionString=”<Azure Storage Connection String>” />
2. XDT transform
Donwload Microsoft.Web.Xdt dll from nuget
Execute following powershell script
function XmlDocTransform($xml, $xdt) | |
{ | |
if (!$xml -or !(Test-Path –path $xml –PathType Leaf)) { | |
throw "File not found. $xml"; | |
} | |
if (!$xdt -or !(Test-Path –path $xdt –PathType Leaf)) { | |
throw "File not found. $xdt"; | |
} | |
$scriptPath = (Get-Variable MyInvocation –Scope 1).Value.InvocationName | split-path –parent | |
Add-Type –LiteralPath "$scriptPath\Microsoft.Web.XmlTransform.dll" | |
$xmldoc = New-Object Microsoft.Web.XmlTransform.XmlTransformableDocument; | |
$xmldoc.PreserveWhitespace = $true | |
$xmldoc.Load($xml); | |
$transf = New-Object Microsoft.Web.XmlTransform.XmlTransformation($xdt); | |
if ($transf.Apply($xmldoc) -eq $false) | |
{ | |
throw "Transformation failed." | |
} | |
$xmldoc.Save($xml); | |
} | |
XmlDocTransform –xml "<PhysicalFolderOfSitecoreWebApp>\App_Config\ConnectionStrings.config" –xdt "<PhysicalFolderOfSitecoreWebApp>\App_Data\Transforms\AzureBlobStorageProvider\Xdts\App_Config\ConnectionStrings.config.xdt" |
Update PhysicalFolderOfSitecoreWebApp in the script before running. Make sure Microsoft.Web.XmlTransform.dll is in the same location where the script is executing.
This will add a connection string node in connectionstrings.config.
Now Sitecore is configured to store blobs in Azure Blob Storage. So when we create new Media items, blobs being stored in Azure Storage. :).
Let’s see how we can implement custom providers to store blobs in any other storage in later posts. 🙂