Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.


Repository files navigation


Official Site Latest version Downloads Build status

This repo will add a Microsoft Azure Cosmos DB storage support to Hangfire - fire-and-forget, delayed and recurring tasks runner for .NET. Scalable and reliable background job runner. Supports multiple servers, CPU and I/O intensive, long-running and short-running jobs.

No Maintaince

Due to current SDK is not being supported anymore, this project will not longer be maitained. If you want the support for the latest SDK v3 Microsoft.Azure.Cosmos, you will have to use [Hangfire.AzureCosmosDb]


Hangfire.AzureDocumentDB is available on NuGet.

Package Manager

PM> Install-Package Hangfire.AzureDocumentDB


> dotnet add package Hangfire.AzureDocumentDB


<PackageReference Include="Hangfire.AzureDocumentDB" Version="0.0.0" />


Use one the following ways to initialize DocumentDbStorage

GlobalConfiguration.Configuration.UseAzureDocumentDbStorage("<url>", "<authSecret>", "<databaseName>", "<collectionName>");

Hangfire.Azure.DocumentDbStorage storage = new Hangfire.Azure.DocumentDbStorage("<url>", "<authSecret>", "<databaseName>", "<collectionName>");
// customize any options
Hangfire.Azure.DocumentDbStorageOptions options = new Hangfire.Azure.DocumentDbStorageOptions
    RequestTimeout = TimeSpan.FromSeconds(30),
    ExpirationCheckInterval = TimeSpan.FromMinutes(2),
    CountersAggregateInterval = TimeSpan.FromMinutes(2),
    QueuePollInterval = TimeSpan.FromSeconds(15),
    ConnectionMode = ConnectionMode.Direct,
    ConnectionProtocol = Protocol.Tcp,
    EnablePartition = false // default: false true; to enable partition on /type

GlobalConfiguration.Configuration.UseAzureDocumentDbStorage("<url>", "<authSecret>", "<databaseName>", "<collectionName>", options);

// or 

Hangfire.Azure.DocumentDbStorage storage = new Hangfire.Azure.DocumentDbStorage("<url>", "<authSecret>", "<databaseName>", "<collectionName>", options);


  • Keep seperate database/collection for the hangfire. (Now you can enable free tier on Azure)
  • Enable partitioning by /type

SDK Support

This package only support using Microsoft.Azure.DocumentDB. If you want the support for the latest SDK v3 Microsoft.Azure.Cosmos, you will have to use Hangfire.AzureCosmosDb

Questions? Problems?

Open-source project are developing more smoothly, when all discussions are held in public.

If you have any questions or problems related to Hangfire.AzureDocumentDB itself or this storage implementation or want to discuss new features, please create under issues and assign the correct label for discussion.

If you've discovered a bug, please report it to the GitHub Issues. Detailed reports with stack traces, actual and expected behavours are welcome.