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.
Hangfire.AzureCosmosDB is available on NuGet.
Package Manager
PM> Install-Package Hangfire.AzureCosmosDB
.NET CLI
> dotnet add package Hangfire.AzureCosmosDB
PackageReference
<PackageReference Include="Hangfire.AzureCosmosDB" Version="0.0.0" />
Use one the following ways to initialize CosmosDbStorage
GlobalConfiguration.Configuration.UseAzureCosmosDbStorage("<url>", "<authSecret>", "<databaseName>", "<collectionName>");
Hangfire.Azure.CosmosDbStorage storage = new Hangfire.Azure.CosmosDbStorage("<url>", "<authSecret>", "<databaseName>", "<collectionName>");
GlobalConfiguration.Configuration.UseStorage(storage);
// customize any options
Hangfire.Azure.CosmosDbStorageOptions options = new Hangfire.Azure.CosmosDbStorageOptions
{
ExpirationCheckInterval = TimeSpan.FromMinutes(2),
CountersAggregateInterval = TimeSpan.FromMinutes(2),
QueuePollInterval = TimeSpan.FromSeconds(15)
};
GlobalConfiguration.Configuration.UseAzureCosmosDbStorage("<url>", "<authSecret>", "<databaseName>", "<collectionName>", cosmoClientOptions, options);
// or
Hangfire.Azure.CosmosDbStorage storage = new Hangfire.Azure.CosmosDbStorage("<url>", "<authSecret>", "<databaseName>", "<collectionName>", cosmoClientOptions, options);
GlobalConfiguration.Configuration.UseStorage(storage);
- Keep seperate database/collection for the hangfire. (Now you can enable free tier on Azure)
This package only supports the latest SDK v3 Microsoft.Azure.Cosmos. If you want the support for the latest SDK v2 Microsoft.Azure.DocumentDB, you will have to use Hangfire.AzureDocumentDB
Open-source project are developing more smoothly, when all discussions are held in public.
If you have any questions or problems related to Hangfire.AzureCosmosDB 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.