Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure function configuration #209

Open
jaques100000 opened this issue May 13, 2021 · 0 comments
Open

Azure function configuration #209

jaques100000 opened this issue May 13, 2021 · 0 comments

Comments

@jaques100000
Copy link

jaques100000 commented May 13, 2021

Hi,

I'm using an Azure Function in c# with Westwind.Globalization.AspnetCore (3.1.2). It works locally with no problems but when deployed in Azure i'm getting...

Westwind.Globalization.AspnetCore: The type initializer for 'Westwind.Globalization.DbResourceConfiguration' threw an exception. Westwind.Utilities: .

My function start-up is as follows...

using FunctionAppGlobalisationTest;
using Microsoft.AspNetCore.Mvc.Localization;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Westwind.Globalization;
using Westwind.Globalization.AspnetCore;

[assembly: WebJobsStartup(typeof(StartUp))]
namespace FunctionAppGlobalisationTest
{
class StartUp : IWebJobsStartup
{
public void Configure(IWebJobsBuilder builder)
{
builder.Services.AddLocalization(options =>
{
options.ResourcesPath = "Properties";
});

        builder.Services.AddSingleton(typeof(IStringLocalizerFactory),
                              typeof(DbResStringLocalizerFactory));
        builder.Services.AddSingleton(typeof(IHtmlLocalizerFactory),
                              typeof(DbResHtmlLocalizerFactory));

        builder.Services.AddWestwindGlobalization(opt =>
        {
            opt.ResourceAccessMode = ResourceAccessMode.DbResourceManager;
            opt.ConnectionString = "myconnectionstring";
            opt.DataProvider = DbResourceProviderTypes.SqlServer;
            opt.ResourceTableName = "Localizations";
            opt.ResourceBaseNamespace = "AppResources";
            opt.AddMissingResources = false; 
            opt.ResxBaseFolder = "~/Properties/";
        }
        );
    }
}

}

I've tried several methods of referencing a configuration file with no luck so I've ended up hard coding the config but that still fails.

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant