You can spin up a Solr using Azure Container Instances for much less than the price of a VM. It is a bit slow, but fine for non-production systems, and you can have a new one in about 5 minutes flat.
This is backed onto an Azure Storage File Share where the actual cores can live.
The PowerShell script below will set you up for less than $50 a month (remember to turn it off when you're not using it). We have other scripts to start and stop the containers every weekday, which saves about 70% of the price.
You should check on https://hub.docker.com/_/solr for the version closest to what your Sitecore will need. Definitely stay on the same major version, and try to stay on the same minor version. Revision is not so important.
$resGrp = "development"
$stgAcc = "mydevstorage"
$stgKey = "***************************************=="
$stgShareName = "proj123"
$location = "australiaeast"
$image = "solr:8.1-slim"
$cpus = 1
$maxRAM = 2
$solrMem = ( $maxRAM * 1024 - 256 )
New-AzContainerGroup -ResourceGroupName $resGrp -Name "my-dev-solr" `
-Image $image -Cpu $cpus -MemoryInGB $maxRAM `
-DnsNameLabel "my-dev-solr-123" -Port 8983 `
-Location $location -OsType Linux -RestartPolicy OnFailure `
-EnvironmentVariable @{ "SOLR_HOME" = "/data/solr"; "SOLR_JAVA_MEM" = "-Xms256m -Xmx$($solrMem)m" } `
-AzureFileVolumeShareName $stgShareName -AzureFileVolumeAccountCredential ( New-Object PSCredential -ArgumentList @( $stgAcc, (ConvertTo-SecureString $stgKey -AsPlainText -Force )) ) `
-AzureFileVolumeMountPath "/data"
But what does this all do?
Glad you asked!
Mostly it's self explanatory but you need an Azure storage account with a "File Share" (not Blob Storage) called, in this case proj123
. In that share create a folder solr
and put your core folders in that. In the root solr
folder you also need the appropriate solr.xml
file. You can copy all that stuff from your web app.
One thing though - this is a public-facing, unencrypted, unsecured Solr, so you need to add some Basic authentication as well.
Create a file called security.json
and put it in the root with solr.xml
. The contents needs to look like this:
{
"authentication":{
"blockUnknown":true,
"class":"solr.BasicAuthPlugin",
"credentials":{"solr":"***************"},
"forwardCredentials":false,
"":{"v":0}
},
"authorization":{
"class":"solr.RuleBasedAuthorizationPlugin",
"user-role":{"solr":"admin"},
"permissions":[{"name":"security-edit","role":"admin"}]
}
}
More detail about the contents of that file (and a default password you can use) including how to change the password using a URL, can be found in the Solr Docs.
Then in Sitecore you need to update your URLs to be http://user@pwd:hostname:8983/solr
but there's also more info about that in the Sitecore docs.