diff --git a/src/Farmer/Builders/Builders.ResourceGroup.fs b/src/Farmer/Builders/Builders.ResourceGroup.fs index a4c00fd98..09d9438e2 100644 --- a/src/Farmer/Builders/Builders.ResourceGroup.fs +++ b/src/Farmer/Builders/Builders.ResourceGroup.fs @@ -86,11 +86,17 @@ type ResourceGroupConfig = interface IDeploymentSource with member this.Deployment= + let rec getPostDeployTasks (resources: IArmResource list) = [ + for resource in resources do + match resource with + | :? IPostDeploy as pd -> pd + | :? ResourceGroupDeployment as rgp -> yield! getPostDeployTasks rgp.Resources + | _ -> () + ] + { Location=this.Location Template = this.Template - PostDeployTasks = - this.Resources - |> List.choose (function | :? IPostDeploy as pd -> Some pd |_ -> None) + PostDeployTasks = getPostDeployTasks this.Resources RequiredResourceGroups = this.Resources |> List.collect (function | :? ResourceGroupDeployment as rg -> rg.RequiredResourceGroups | _ -> []) diff --git a/src/Tests/ResourceGroup.fs b/src/Tests/ResourceGroup.fs index ab0e944f5..e4f74edc4 100644 --- a/src/Tests/ResourceGroup.fs +++ b/src/Tests/ResourceGroup.fs @@ -35,4 +35,18 @@ let tests = testList "Resource Group" [ |> List.map (fun x -> x.ResourceId.Name.Value) Expect.equal nestedResources ["stg1";"stg2";"stg3"] "all three storage accounts should be nested" } + test "zip_deploy should be performed when declared in a nested resource" { + let webApp = webApp { + name "webapp" + zip_deploy "deploy" + } + + let oneNestedLevel = resourceGroup { add_resource webApp } + let twoNestedLevels = resourceGroup { add_resource oneNestedLevel } + let threeNestedLevels = arm { add_resource twoNestedLevels } + + Expect.isNonEmpty + (threeNestedLevels :> IDeploymentSource).Deployment.PostDeployTasks + "The zip_deploy should create a post deployment task" + } ]