Reputation: 23
We are using Kentico 13 and developing a new site using ASP.NET Core. For deployment, we have leveraged Azure DevOps pipelines. When deploying our new site, all data in App_Data is being wiped. Which includes smart search indexes. So after each deployment, we have to initialize the rebuild of indexes. I was thinking that we could add a script to copy existing App_Data folder to some temp directory before deployment and after the deployment is finished, copy the App_Data folder back. Is this a good approach, is there any other way to solve this problem from your experience?
Upvotes: 1
Views: 255
Reputation: 18235
We use Azure DevOps pipelines but the App_Data folder is persisted between deployments.
Which DevOps yml task are you using?
AzureRmWebAppDeployment@4 has settings to ensure this folder is not removed, specifically RemoveAdditionalFilesFlag
and ExcludeFilesFromAppDataFlag
.
If you don't want to use those, Zach's method works.
You can also use an ASP.NET Core startup filter, which the Dancing Goat sample site uses to rebuild the index on startup.
services.AddSingleton<IStartupFilter>(new SmartSearchIndexRebuildStartupFilter());
public class SmartSearchIndexRebuildStartupFilter : IStartupFilter
{
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
{
return builder =>
{
// Ensures smart search index rebuild upon installation or deployment
builder.UseMiddleware<SmartSearchIndexRebuildMiddleware>();
next(builder);
};
}
}
Upvotes: 1
Reputation: 756
In previous versions I have used Kentico's global events to trigger a smart search rebuild on App Start. So after you deploy your code, soon as the app starts the smart search will rebuild. If you use web farm you could potentially have this rebuilding more than you want though.
Upvotes: 0