Skip to content

Commit 28a80c5

Browse files
Refactor Event Hubs for basic SKU
Refactored Azure Event Hubs configuration to support broader infrastructure settings, including namespace SKU and retention policy. Replaced `eventHub` with `eventHubs` and updated the `AddHub` method to include hub-specific properties like `PartitionCount`. Removed unused SQL provisioning directive. Cosmos DB configuration remains unchanged.
1 parent ce906e7 commit 28a80c5

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/services/host/Codebreaker.AppHost/AppHost.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Azure.Provisioning.AppContainers;
22
using Azure.Provisioning.EventHubs;
3-
using Azure.Provisioning.Sql;
43

54
var builder = DistributedApplication.CreateBuilder(args);
65

@@ -67,7 +66,7 @@
6766
var botQueue = storage.AddQueues("botqueue");
6867
var blob = storage.AddBlobs("checkpoints");
6968

70-
var eventHub = builder.AddAzureEventHubs("codebreakerevents")
69+
var eventHubs = builder.AddAzureEventHubs("codebreakerevents")
7170
.ConfigureInfrastructure(infrastructure =>
7271
{
7372
var eventHubsNamespace = infrastructure.GetProvisionableResources().OfType<EventHubsNamespace>().Single();
@@ -76,9 +75,20 @@
7675
Name = EventHubsSkuName.Basic,
7776
Tier = EventHubsSkuTier.Basic
7877
};
78+
79+
var eventHub = infrastructure.GetProvisionableResources().OfType<EventHub>().Single();
80+
eventHub.RetentionDescription = new RetentionDescription()
81+
{
82+
CleanupPolicy = CleanupPolicyRetentionDescription.Delete,
83+
RetentionTimeInHours = 24
84+
};
7985
});
8086

81-
eventHub.AddHub("games");
87+
var eventHub = eventHubs.AddHub("games", hubName: "games")
88+
.WithProperties(config =>
89+
{
90+
config.PartitionCount = 1;
91+
});
8292

8393
var cosmos = builder.AddAzureCosmosDB("codebreakercosmos")
8494
.AddCosmosDatabase("codebreaker");

0 commit comments

Comments
 (0)