Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Henrik Sunesen 84 posts 281 karma points
    Oct 10, 2021 @ 15:30
    Henrik Sunesen
    0

    Hangire + Umbraco 9 + Cloud, connectionstring issues

    Hi,

    I'm trying to get Hangfire working with U9 on the cloud.

    I followed the guide: https://www.umbrajobs.com/blog/posts/2021/june/umbraco-9-configuring-hangfire-scheduled-tasks/

    But i'm facing a issue (InvalidOperationException: The ConnectionString property has not been initialized.)

    Startup.cs

       public void ConfigureServices(IServiceCollection services)
        {
            services.AddUmbraco(_env, _config)
                .AddBackOffice()
                .AddWebsite()
                .AddComposers()
                .Build();
    
            services.AddHangfire(c => c.UseSqlServerStorage(_config.GetConnectionString("umbracoDbDSN")));
            GlobalConfiguration.Configuration.UseSqlServerStorage(_config.GetConnectionString("umbracoDbDSN")).WithJobExpirationTimeout(TimeSpan.FromDays(7));
    
        }
    
     public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IBackgroundJobClient backgroundJobClient, IRecurringJobManager recurringJobManager, IHangfireTasks hangfireTasks)
        {
          Standard stuff.......
    
            app.UseHangfireServer();
    
            //No Authentication
            app.UseHangfireDashboard("/hangfire", new DashboardOptions()
            {
                AppPath = null,
                DashboardTitle = "Hangfire Dashboard"
            });
    
            // Recurring Job for every 1 min 
            recurringJobManager.AddOrUpdate("TestScheduledTask : Runs Every 1 Min", () => hangfireTasks.TestScheduledTask(), Cron.Minutely);
    

    }

    The tables has been created in the DB.

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Oct 10, 2021 @ 17:10
    Bjarne Fyrstenborg
    1

    Hi Henrik

    Did you had a look at the package from Sebastiaan here? https://our.umbraco.com/packages/developer-tools/cultivhangfire/

    Specifically regarding this line to set JobStorage.Current. I haven't looked at Hangfire in Umbraco 9 yet, but hopefully it will help :) https://github.com/nul800sebastiaan/Cultiv.Hangfire/blob/main/Cultiv.Hangfire/HangfireComposer.cs#L45-L47

    /Bjarne

  • Henrik Sunesen 84 posts 281 karma points
    Oct 14, 2021 @ 17:16
    Henrik Sunesen
    0

    Thanks, I will try to look at that :)

Please Sign in or register to post replies

Write your reply to:

Draft