@@ -104,7 +104,6 @@ public CloudMachineInfrastructure(string name = "cm") : base(name!)
104104 _serviceBusTopic_app = new ( $ "{ _name } _sb_topic_app", "2021-11-01" )
105105 {
106106 Parent = _serviceBusNamespace ,
107- // Name = "default",
108107 MaxMessageSizeInKilobytes = 256 ,
109108 DefaultMessageTimeToLive = new StringLiteral ( "P14D" ) ,
110109 RequiresDuplicateDetection = false ,
@@ -141,7 +140,7 @@ public CloudMachineInfrastructure(string name = "cm") : base(name!)
141140 IdentityType = EventSubscriptionIdentityType . UserAssigned ,
142141 UserAssignedIdentity = _identity . Id
143142 } ,
144- Destination = new EventHubEventSubscriptionDestination
143+ Destination = new ServiceBusTopicEventSubscriptionDestination
145144 {
146145 ResourceId = _serviceBusTopic_main . Id
147146 }
@@ -195,14 +194,17 @@ public override ProvisioningPlan Build(ProvisioningContext? context = null)
195194 Add ( _serviceBusSubscription_app ) ;
196195
197196 // This is necessary until SystemTopic adds an AssignRole method.
198- var role = ServiceBusBuiltInRole . AzureServiceBusDataOwner ;
199- RoleAssignment roleAssignment = new RoleAssignment ( _eventGridTopic_Blobs . ResourceName + "_" + _identity . ResourceName + "_" + ServiceBusBuiltInRole . GetBuiltInRoleName ( role ) ) ;
200- roleAssignment . Name = BicepFunction . CreateGuid ( _eventGridTopic_Blobs . Id , _identity . Id , BicepFunction . GetSubscriptionResourceId ( "Microsoft.Authorization/roleDefinitions" , role . ToString ( ) ) ) ;
201- roleAssignment . Scope = new IdentifierExpression ( _eventGridTopic_Blobs . ResourceName ) ;
197+ var role = ServiceBusBuiltInRole . AzureServiceBusDataSender ;
198+ RoleAssignment roleAssignment = new RoleAssignment ( _serviceBusNamespace . ResourceName + "_" + _identity . ResourceName + "_" + ServiceBusBuiltInRole . GetBuiltInRoleName ( role ) ) ;
199+ roleAssignment . Name = BicepFunction . CreateGuid ( _serviceBusNamespace . Id , _identity . Id , BicepFunction . GetSubscriptionResourceId ( "Microsoft.Authorization/roleDefinitions" , role . ToString ( ) ) ) ;
200+ roleAssignment . Scope = new IdentifierExpression ( _serviceBusNamespace . ResourceName ) ;
202201 roleAssignment . PrincipalType = RoleManagementPrincipalType . ServicePrincipal ;
203202 roleAssignment . RoleDefinitionId = BicepFunction . GetSubscriptionResourceId ( "Microsoft.Authorization/roleDefinitions" , role . ToString ( ) ) ;
204203 roleAssignment . PrincipalId = _identity . PrincipalId ;
205204 Add ( roleAssignment ) ;
205+ // the role assignment must exist before the system topic event subscription is created.
206+ _systemTopicEventSubscription . DependsOn . Add ( roleAssignment ) ;
207+
206208 Add ( _systemTopicEventSubscription ) ;
207209 Add ( _eventGridTopic_Blobs ) ;
208210
0 commit comments