Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit cce3c98

Browse files
authored
Provide docs on generic CloudEvent & Key Vault secret job (#2)
* Provide docs on generic CloudEvent & Key Vault secret job Signed-off-by: Tom Kerkhove <[email protected]> * Configuration on Netlify works * Change title
1 parent 13b0d35 commit cce3c98

File tree

3 files changed

+102
-1
lines changed

3 files changed

+102
-1
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: "Securely Receive CloudEvents"
3+
layout: default
4+
---
5+
6+
# Securely Receive CloudEvents
7+
8+
The `Arcus.BackgroundJobs` library provides a collection of background jobs to securely receive [CloudEvents](https://github.com/cloudevents/spec).
9+
This allows workloads to asynchronously process event from other components without exposing a public endpoint.
10+
11+
## How does it work?
12+
13+
An Azure Service Bus Topic resource is required to receive CloudEvents on. CloudEvent messages on this Topic will be processed by a background job.
14+
15+
You can write your own background job(s) by deriving from `CloudEventBackgroundJob` which already takes care of topic subscription creation/deletion on start/stop of the job.
16+
17+
## Usage
18+
19+
You can easily implement your own job by implementing the `ProcessMessageAsync` method to prcocess new CloudEvents.
20+
21+
```csharp
22+
public class MyBackgroundJob : CloudEventBackgroundJob
23+
{
24+
public MyBackgroundJob(
25+
IConfiguration configuration,
26+
IServiceProvider serviceProvider,
27+
ILogger<CloudEventBackgroundJob> logger) : base(configuration, serviceProvider, logger)
28+
{
29+
30+
}
31+
32+
protected override async Task ProcessMessageAsync(
33+
CloudEvent message,
34+
AzureServiceBusMessageContext messageContext,
35+
MessageCorrelationInfo correlationInfo,
36+
CancellationToken cancellationToken)
37+
{
38+
// Process the CloudEvent message...
39+
}
40+
}
41+
```
42+
43+
[&larr; back](/)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: "Automatically Invalidate Azure Key Vault Secrets"
3+
layout: default
4+
---
5+
6+
# Automatically Invalidate Azure Key Vault Secrets
7+
8+
The `Arcus.WebApi.Jobs` library provides a background job to automatically invalidate cached Azure Key Vault secrets from an `ICachedSecretProvider` instance of your choice.
9+
10+
## How does it work?
11+
12+
This automation works by subscribing on the `SecretNewVersionCreated` event of an Azure Key Vault resource and placing those events on a Azure Service Bus Topic; which we process in our background job.
13+
14+
To make this automation opperational, following Azure Resources has to be used:
15+
* Azure Key Vault instance
16+
* Azure Service Bus Topic
17+
* Azure Event Grid subscription for `SecretNewVersionCreated` events that are sent to the Azure Service Bus Topic
18+
19+
## Usage
20+
21+
Our background job has to be configured in `ConfigureServices` method:
22+
23+
```csharp
24+
public void ConfigureServices(IServiceCollection services)
25+
{
26+
// An 'ISecretProvider' implementation (see: https://security.arcus-azure.net/) to access the Azure Service Bus Topic resource;
27+
// this will get the 'serviceBusTopicConnectionStringSecretKey' string (configured below) and has to retrieve the connection string for the topic.
28+
services.AddSingleton<ISecretProvider>(serviceProvider => ...);
29+
30+
// An `ICachedSecretProvider` implementation which secret keys will automatically be invalidated.
31+
services.AddSingleton<ICachedSecretProvider>(serviceProvider => new CachedSecretProvider(mySecretProvider));
32+
33+
services.AddAutoInvalidateKeyVaultSecretBackgroundJob(
34+
// Prefix of the Azure Service Bus Topic subscription;
35+
// this allows the background jobs to support applications that are running multiple instances, processing the same type of events, without conflicting subscription names.
36+
subscriptionNamePrefix: "MyPrefix"
37+
38+
// Connection string secret key to a Azure Service Bus Topic.
39+
serviceBusTopicConnectionStringSecretKey: "MySecretKeyToServiceBusTopicConnectionString");
40+
}
41+
```
42+
43+
[&larr; back](/)

docs/index.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,24 @@ redirect_from:
66
- /index.html
77
---
88

9+
[![NuGet Badge](https://buildstats.info/nuget/Arcus.BackgroundJobs?includePreReleases=true)](https://www.nuget.org/packages/Arcus.BackgroundJobs/)
10+
911
# Installation
1012

11-
Coming soon!
13+
The Arcus.BackgroundJobs can be installed via NuGet:
14+
15+
```shell
16+
PM > Install-Package Arcus.BackgroundJobs
17+
```
18+
19+
For more granular packages we recommend reading the documentation.
20+
21+
# Features
22+
23+
- **General**
24+
- [Securely Receive CloudEvents](features/cloudevent/receive-cloudevents-job)
25+
- **Security**
26+
- [Automatically invalidate cached secrets from Azure Key Vault](features/security/auto-invalidate-secrets)
1227

1328
# License
1429
This is licensed under The MIT License (MIT). Which means that you can use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the web application. But you always need to state that Codit is the original author of this web application.

0 commit comments

Comments
 (0)