“The culture specified was not found in any configured sources for this service” in the log files (Azure) - V13

Hello,

We are seeing the following as a warning in the logfiles within Umbraco

“The culture specified was not found in any configured sources for this service” and this appears to happen in the Azure environment and not locally.

I found this The culture specified '' was not found in any configured sources for this service - Linux App Service Plan · Issue #13980 · umbraco/Umbraco-CMS · GitHub with the last comment saying it effects 3.10.1

“This affects v/13 and is still an issue with 13.10.1 .”

There is a link to a solution here - How to use default language as default culture for... | UmbraCare, which describes the problems and offers a solution.

Has any one done this? and does it fix the issue?

Thanks :slight_smile:

1 Like

Hi @charlesa-ccs

The GitHub issue does mention that as a solution when running in Linux on an Azure web app. The issue has not been solved by HQ so you may want to try the workaround to see if it resolves your issue too.

Justin

1 Like

The warnings come from the localization service. So by itself - in many case - it’s not REALLY an issue because it’s mostly about some localization that fails.

The issue is indeed that there is no default culture set on Linux, and the OS of containers of Web Apps in Azure are Linux based. On normal requests, Umbraco can infer the UI culture or gets is through a header. On background jobs, there obviously is no request, so Umbraco has no idea what language to use.

I don’t know the exact detailt, but you can just set a default UI language:

  • In Azure, set a application setting of LANG to (for instance) en_US.UTF-8. This effectively set the default language.

  • If you want it to set it on the application level, before app.Run() set the default languages:

    CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(“en-US”);
    CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(“en-US”);

I haven’t tried it myself yet, but this should give you some pointers :slight_smile:

2 Likes

Thanks @Luuk for that information, that’s brilliant!. That’s an option. I would prefer not to set it in Azure for each environment but its an option for sure :smiley:

This works for Umbraco 13:

  • no more warnings about the culture in our logs
  • but this does not update the default culture when the default language is changed from the backoffice, has to restart AFAIK
  • i don’t know if the issue still exists in Umbraco 17, will tackle that later today probably
using System.Globalization;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Persistence.Repositories;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Scoping;

namespace YOUR_NAMESPACE;

public class DefaultCultureComposer : ComponentComposer<DefaultCultureComponent> { }

// ReSharper disable once ClassNeverInstantiated.Global
public class DefaultCultureComponent(
	IRuntimeState runtimeState,
	IScopeProvider scopeProvider,
	ILanguageRepository languageRepository)
	: IComponent
{
	public void Initialize()
	{
		if (runtimeState.Level < RuntimeLevel.Run)
			return;

		using var scope = scopeProvider.CreateScope();
		var defaultIsoCode = languageRepository.GetDefaultIsoCode();
		var defaultCulture = new CultureInfo(defaultIsoCode);

		CultureInfo.DefaultThreadCurrentCulture = defaultCulture;
		CultureInfo.DefaultThreadCurrentUICulture = defaultCulture;
	}

	public void Terminate() { }
}

Thanks @markadrake apricated :smiley:

1 Like

Great touch using the default language of Umbraco to set the default language. That’s better than hardcoding it :slight_smile:

1 Like