CompositionalIT / farmer

Repeatable Azure deployments with ARM templates - made easy!
https://compositionalit.github.io/farmer
MIT License
517 stars 156 forks source link

Add support for Resource Group as a source and Azure Function as a target of Event Grid #1034

Closed et1975 closed 1 year ago

et1975 commented 1 year ago

This PR closes #1029 and #1030

The changes in this PR are as follows:

I think the latter overload will be more widely used as the handler, not just the function has to exist when subscription is created. This means the code has be deployed that exposes the handler, which is often a separate from ARM step.

I have read the contributing guidelines and have completed the following:

Below is a minimal example configuration that includes the new features, which can be used to deploy to Azure:


/// Send events to this function that was deployed separately
let fnRef = 
    { Arm.Web.siteFunctions.resourceId(ResourceName "gridFnApp", ResourceName "eventHandler") with 
        ResourceGroup = Some "fn-rg" }
    |> Unmanaged

/// The source will default to the resourceGroup() and event grid target will be the function handler.
let grid = eventGrid {
    topic_name "src-rg-events"
    add_function_subscriber fnRef 
        { MaxEventsPerBatch = 1u; PreferredBatchSizeInKilobytes = 64u }
        [ SystemEvents.Resources.ResourceWriteSuccess; SystemEvents.Resources.ResourceActionSuccess ]
}

// deploy into the resource group that we want to be the source of events
let deployment = arm {
    add_resources [
        grid
    ]
}
ninjarobot commented 1 year ago

Thanks again @et1975 for the complete PR.

ninjarobot commented 1 year ago

Thanks @et1975, this is in the 1.7.22 release now available on nuget.