Skip to content

Commit

Permalink
Merge pull request #1103 from MartinWa/message_payload_size
Browse files Browse the repository at this point in the history
Add support for setting service bus max message size
  • Loading branch information
ninjarobot authored Jun 9, 2024
2 parents 39ead0e + e995755 commit f4dd08c
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
6 changes: 5 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
Release Notes
=============

## 1.8.11
* Service Bus: Added support for setting max message size.

## 1.8.10
* Functions: Added support for setting max scale out limit
* Functions: Added support for setting max scale out limit.

## 1.8.9
* Managed Identity: Support for federated identity credentials.
Expand Down
1 change: 1 addition & 0 deletions docs/content/api-overview/resources/service-bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The Service Bus builder creates service bus namespaces and their associated queu
| Topic | duplicate_detection | Whether to enable duplicate detection, and if so, how long to check for. |
| Topic | duplicate_detection_minutes | Whether to enable duplicate detection, and if so, how long to check for in minutes. |
| Topic | enable_partition | Enables partition support on the topic. |
| Topic | max_message_size | The maximum size of the message payload that can be accepted by the topic in Kilobytes e.g `1024<Kb>`. **Requires Premium SKU.** |
| Topic | max_topic_size | Maximum size for the topic in Megabytes e.g. `1024<Mb>`. |
| Topic | message_ttl | Time To Live (TTL) value for messages expressed as a TimeSpan or a TimeSpan string, such as '01:30:00' 1 hour, 30 minutes, or as an integer days e.g. `4<Days>`. |
| Topic | link_to_unmanaged_namespace | Instead of creating or modifying a namespace, configure this topic to point to another unmanaged namespace instance. |
Expand Down
2 changes: 2 additions & 0 deletions src/Farmer/Arm/ServiceBus.fs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ module Namespaces =
DuplicateDetectionHistoryTimeWindow: IsoDateTime option
DefaultMessageTimeToLive: IsoDateTime option
EnablePartitioning: bool option
MaxMessageSizeInKilobytes: int<Kb> option
MaxSizeInMegabytes: int<Mb> option
}

Expand All @@ -208,6 +209,7 @@ module Namespaces =
| None -> Nullable()
duplicateDetectionHistoryTimeWindow = tryGetIso this.DuplicateDetectionHistoryTimeWindow
enablePartitioning = this.EnablePartitioning |> Option.toNullable
maxMessageSizeInKilobytes = this.MaxMessageSizeInKilobytes |> Option.toNullable
maxSizeInMegabytes = this.MaxSizeInMegabytes |> Option.toNullable
|}
|}
Expand Down
10 changes: 10 additions & 0 deletions src/Farmer/Builders/Builders.ServiceBus.fs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ type ServiceBusTopicConfig =
DuplicateDetection: TimeSpan option
DefaultMessageTimeToLive: TimeSpan option
EnablePartitioning: bool option
MaxMessageSizeInKilobytes: int<Kb> option
MaxSizeInMegabytes: int<Mb> option
Subscriptions: Map<ResourceName, ServiceBusSubscriptionConfig>
}
Expand Down Expand Up @@ -356,6 +357,7 @@ type ServiceBusTopicConfig =
DuplicateDetectionHistoryTimeWindow = this.DuplicateDetection |> Option.map IsoDateTime.OfTimeSpan
DefaultMessageTimeToLive = this.DefaultMessageTimeToLive |> Option.map IsoDateTime.OfTimeSpan
EnablePartitioning = this.EnablePartitioning
MaxMessageSizeInKilobytes = this.MaxMessageSizeInKilobytes
MaxSizeInMegabytes = this.MaxSizeInMegabytes
}
for subscription in this.Subscriptions do
Expand All @@ -376,6 +378,7 @@ type ServiceBusTopicBuilder() =
DuplicateDetection = None
DefaultMessageTimeToLive = None
EnablePartitioning = None
MaxMessageSizeInKilobytes = None
MaxSizeInMegabytes = None
Subscriptions = Map.empty
}
Expand Down Expand Up @@ -403,6 +406,13 @@ type ServiceBusTopicBuilder() =
DuplicateDetection = Some(TimeSpan.FromMinutes(float maxTimeWindow))
}

/// The maximum size of the message payload that can be accepted by the topic in kilobytes.
[<CustomOperation "max_message_size">]
member _.MaxMessageSize(state: ServiceBusTopicConfig, maxMessageSizeInKilobytes: int<Kb>) =
{ state with
MaxMessageSizeInKilobytes = Some maxMessageSizeInKilobytes
}

/// The maximum size for the topic in megabytes.
[<CustomOperation "max_topic_size">]
member _.MaxTopicSize(state: ServiceBusTopicConfig, maxTopicSize: int<Mb>) =
Expand Down
22 changes: 20 additions & 2 deletions src/Tests/ServiceBus.fs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ let tests =

Expect.equal sbAuthorizationRule.Name "serviceBus/my-queue/my-rule" "Name is wrong"
Expect.equal sbAuthorizationRule.Rights.Count 1 "Wrong number of rights"
Expect.equal sbAuthorizationRule.Rights.[0] (Nullable AccessRights.Manage) "Wrong rights"
Expect.equal sbAuthorizationRule.Rights.[0] AccessRights.Manage "Wrong rights"
}

test "Queue IArmResource has correct resourceId for unmanaged namespace" {
Expand Down Expand Up @@ -577,6 +577,24 @@ let tests =
(Nullable(TimeSpan.FromMinutes 15.))
"Duplicate detection time incorrect"
}
test "Can create a topic with a max message size" {
let topic: SBTopic =
serviceBus {
name "my-bus"

add_topics
[
topic {
name "my-topic"
max_message_size 1024<Kb>
}
]
}
|> getResourceAtIndex 1

Expect.equal topic.Name "my-bus/my-topic" "Name not set"
Expect.equal topic.MaxMessageSizeInKilobytes (Nullable 1024) "Max message size not set"
}
test "Can create a topic with a max size" {
let topic: SBTopic =
serviceBus {
Expand Down Expand Up @@ -954,7 +972,7 @@ let tests =

Expect.equal sbAuthorizationRule.Name "serviceBus/my-rule" "Wrong name"
Expect.equal sbAuthorizationRule.Rights.Count 1 "Wrong number of rights"
Expect.equal sbAuthorizationRule.Rights.[0] (Nullable AccessRights.Manage) "Wrong rights"
Expect.equal sbAuthorizationRule.Rights.[0] AccessRights.Manage "Wrong rights"
}
]
]
2 changes: 1 addition & 1 deletion src/Tests/Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.20.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.21.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.10.1-preview" />
<PackageReference Include="Microsoft.Azure.Management.ServiceBus" Version="2.1.0" />
<PackageReference Include="Microsoft.Azure.Management.ServiceBus" Version="5.0.0" />
<PackageReference Include="Microsoft.Azure.Management.SignalR" Version="1.0.1" />
<PackageReference Include="Microsoft.Azure.Management.Sql" Version="1.43.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="21.0.0" />
Expand Down

0 comments on commit f4dd08c

Please sign in to comment.