-
Notifications
You must be signed in to change notification settings - Fork 20
eventstream attribute
Duncan Jones edited this page Oct 31, 2020
·
2 revisions
This attribute can be applied to an instance of an eventstream class in the definition of an Azure serverless function to have the instance of that event stream created by dependency injection at run time.
public EventStreamAttribute(string domainName,
string entityTypeName,
string instanceKey,
string notificationDispatcherName = "")
- DomainName (string) - The name of the domain in which the entity that this event stream is found
- EntityTypeName (string) - The type of the entity for which this event stream is defined
- InstanceKey (string) - The unique identifier of the instance of that entity
- NotificationDispatcherName (string) - The name of the dispatcher to use to send notification messages for changes to the event stream (optional)
To create an event stream reference to use in an Azure Function you can use the eventstream attribute to declare it in the function:
[FunctionName("OpenAccount")]
public static async Task<HttpResponseMessage> OpenAccountRun(
[HttpTrigger(AuthorizationLevel.Function, "POST", Route = @"OpenAccount/{accountnumber}")]HttpRequestMessage req,
string accountnumber,
[EventStream("Bank", "Account", "{accountnumber}")] EventStream bankAccountEvents)
The event stream variable if then available for use within the body of the function:
Account.Events.BeneficiarySet evtBeneficiary = new Account.Events.BeneficiarySet()
{ BeneficiaryName = data.ClientName };
await bankAccountEvents.AppendEvent(evtBeneficiary);