Skip to content

Commit c01c835

Browse files
authored
[Hub apps] Create the hub-event-trigger module for creating ADF triggers (#1493)
1 parent 23b5d72 commit c01c835

File tree

3 files changed

+143
-74
lines changed

3 files changed

+143
-74
lines changed

Diff for: docs-mslearn/toolkit/changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ The following section lists features and enhancements that are currently in deve
3535
- Created a new bicep modules to support extensibility:
3636
- The **hub-app** module tracks telemetry when an app is deployed.
3737
- The **hub-storage** module creates containers in the hub storage account.
38+
- The **hub-event-trigger** module creates a trigger in the hub Data Factory instance.
3839
- The **hub-vault** module adds secrets to the hub vault.
3940

4041
**Fixed**

Diff for: src/templates/finops-hub/modules/dataFactory.bicep

+47-74
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ resource stopTriggers 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
425425
//------------------------------------------------------------------------------
426426

427427
// cSpell:ignore linkedservices
428+
// TODO: Move to the hub-app module
428429
resource linkedService_keyVault 'Microsoft.DataFactory/factories/linkedservices@2018-06-01' = if (!empty(remoteHubStorageUri)) {
429430
name: keyVault.name
430431
parent: dataFactory
@@ -443,6 +444,7 @@ resource linkedService_keyVault 'Microsoft.DataFactory/factories/linkedservices@
443444
}
444445
}
445446

447+
// TODO: Move to the hub-app module
446448
resource linkedService_storageAccount 'Microsoft.DataFactory/factories/linkedservices@2018-06-01' = {
447449
name: storageAccount.name
448450
parent: dataFactory
@@ -812,97 +814,68 @@ resource dataset_ftkReleaseFile 'Microsoft.DataFactory/factories/datasets@2018-0
812814
// Triggers
813815
//------------------------------------------------------------------------------
814816

815-
resource trigger_ExportManifestAdded 'Microsoft.DataFactory/factories/triggers@2018-06-01' = {
816-
name: exportManifestAddedTriggerName
817-
parent: dataFactory
817+
// TODO: Create apps_PublishEvent pipeline { event, properties }
818+
819+
module trigger_ExportManifestAdded 'hub-event-trigger.bicep' = {
820+
name: 'trigger_ExportManifestAdded'
818821
dependsOn: [
819822
stopTriggers
820823
]
821-
properties: {
822-
annotations: []
823-
pipelines: [
824-
{
825-
pipelineReference: {
826-
referenceName: pipeline_ExecuteExportsETL.name
827-
type: 'PipelineReference'
828-
}
829-
parameters: {
830-
folderPath: '@triggerBody().folderPath'
831-
fileName: '@triggerBody().fileName'
832-
}
833-
}
834-
]
835-
type: 'BlobEventsTrigger'
836-
typeProperties: {
837-
blobPathBeginsWith: '/${exportContainerName}/blobs/'
838-
blobPathEndsWith: 'manifest.json'
839-
ignoreEmptyBlobs: true
840-
scope: storageAccount.id
841-
events: [
842-
'Microsoft.Storage.BlobCreated'
843-
]
824+
params: {
825+
dataFactoryName: dataFactory.name
826+
triggerName: exportManifestAddedTriggerName
827+
828+
// TODO: Replace pipeline with event: 'Microsoft.FinOpsToolkit.CostManagement.ExportManifestAdded'
829+
pipelineName: pipeline_ExecuteExportsETL.name
830+
pipelineParameters: {
831+
folderPath: '@triggerBody().folderPath'
832+
fileName: '@triggerBody().fileName'
844833
}
834+
835+
storageAccountName: storageAccount.name
836+
storageContainer: exportContainerName
837+
storagePathEndsWith: 'manifest.json'
845838
}
846839
}
847840

848-
resource trigger_IngestionManifestAdded 'Microsoft.DataFactory/factories/triggers@2018-06-01' = if (deployDataExplorer) {
849-
name: ingestionManifestAddedTriggerName
850-
parent: dataFactory
841+
module trigger_IngestionManifestAdded 'hub-event-trigger.bicep' = {
842+
name: 'trigger_IngestionManifestAdded'
851843
dependsOn: [
852844
stopTriggers
853845
]
854-
properties: {
855-
annotations: []
856-
pipelines: [
857-
{
858-
pipelineReference: {
859-
referenceName: pipeline_ExecuteIngestionETL.name
860-
type: 'PipelineReference'
861-
}
862-
parameters: {
863-
folderPath: '@triggerBody().folderPath'
864-
}
865-
}
866-
]
867-
type: 'BlobEventsTrigger'
868-
typeProperties: {
869-
blobPathBeginsWith: '/${ingestionContainerName}/blobs/'
870-
blobPathEndsWith: 'manifest.json'
871-
ignoreEmptyBlobs: true
872-
scope: storageAccount.id
873-
events: [
874-
'Microsoft.Storage.BlobCreated'
875-
]
846+
params: {
847+
dataFactoryName: dataFactory.name
848+
triggerName: ingestionManifestAddedTriggerName
849+
850+
// TODO: Replace pipeline with event: 'Microsoft.FinOpsToolkit.Hubs.IngestionManifestAdded'
851+
pipelineName: pipeline_ExecuteIngestionETL.name
852+
pipelineParameters: {
853+
folderPath: '@triggerBody().folderPath'
876854
}
855+
856+
storageAccountName: storageAccount.name
857+
storageContainer: ingestionContainerName
858+
storagePathEndsWith: 'manifest.json'
877859
}
878860
}
879861

880-
resource trigger_SettingsUpdated 'Microsoft.DataFactory/factories/triggers@2018-06-01' = {
881-
name: updateConfigTriggerName
882-
parent: dataFactory
862+
module trigger_SettingsUpdated 'hub-event-trigger.bicep' = {
863+
name: 'trigger_SettingsUpdated'
883864
dependsOn: [
884865
stopTriggers
885866
]
886-
properties: {
887-
annotations: []
888-
pipelines: [
889-
{
890-
pipelineReference: {
891-
referenceName: pipeline_ConfigureExports.name
892-
type: 'PipelineReference'
893-
}
894-
}
895-
]
896-
type: 'BlobEventsTrigger'
897-
typeProperties: {
898-
blobPathBeginsWith: '/${configContainerName}/blobs/'
899-
blobPathEndsWith: 'settings.json'
900-
ignoreEmptyBlobs: true
901-
scope: storageAccount.id
902-
events: [
903-
'Microsoft.Storage.BlobCreated'
904-
]
905-
}
867+
params: {
868+
dataFactoryName: dataFactory.name
869+
triggerName: updateConfigTriggerName
870+
871+
// TODO: Replace pipeline with event: 'Microsoft.FinOpsToolkit.Hubs.SettingsUpdated'
872+
pipelineName: pipeline_ConfigureExports.name
873+
pipelineParameters: {}
874+
875+
storageAccountName: storageAccount.name
876+
storageContainer: configContainerName
877+
// TODO: Change this to startswith
878+
storagePathEndsWith: 'settings.json'
906879
}
907880
}
908881

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
//==============================================================================
5+
// Parameters
6+
//==============================================================================
7+
8+
@description('Required. Name of the publisher-specific Data Factory instance.')
9+
param dataFactoryName string
10+
11+
@description('Required. Name of the Data Factory trigger to create or update.')
12+
param triggerName string
13+
14+
// Storage details
15+
@description('Optional. Azure storage container to monitor for updates and trigger events for.')
16+
param storageAccountName string = ''
17+
@description('Optional. Azure storage container to monitor for updates and trigger events for.')
18+
param storageContainer string = ''
19+
@description('Optional. Beginning of the storage path within the specified storageContainer to monitor for updates and trigger events for.')
20+
param storagePathStartsWith string = ''
21+
@description('Optional. End of the storage path to monitor for updates and trigger events for.')
22+
param storagePathEndsWith string = ''
23+
24+
// Target pipeline details
25+
@description('Required. Name of the Data Factory pipeline to execute when the trigger is executed.')
26+
param pipelineName string
27+
@description('Required. Parameters to pass to the pipeline when the trigger is executed.')
28+
param pipelineParameters object
29+
// @description('Required. Fully-qualified identifier of the event to publish.')
30+
// param event string
31+
32+
33+
//==============================================================================
34+
// Resources
35+
//==============================================================================
36+
37+
//------------------------------------------------------------------------------
38+
// Get references to existing resources
39+
//------------------------------------------------------------------------------
40+
41+
resource storageAccount 'Microsoft.Storage/storageAccounts@2024-01-01' existing = {
42+
name: storageAccountName
43+
}
44+
45+
//------------------------------------------------------------------------------
46+
// Create trigger
47+
//------------------------------------------------------------------------------
48+
49+
resource dataFactory 'Microsoft.DataFactory/factories@2018-06-01' existing = {
50+
name: dataFactoryName
51+
52+
resource storageTrigger 'triggers' = if (!empty(storageAccountName)) {
53+
name: triggerName
54+
properties: {
55+
annotations: []
56+
pipelines: [
57+
{
58+
// TODO: Replace with apps_PublishEvent pipeline when event publishing is enabled
59+
pipelineReference: {
60+
referenceName: pipelineName
61+
type: 'PipelineReference'
62+
}
63+
parameters: pipelineParameters
64+
65+
// pipelineReference: {
66+
// referenceName: 'apps_PublishEvent'
67+
// type: 'PipelineReference'
68+
// }
69+
// parameters: {
70+
// event: event
71+
// properties: '@triggerBody()' // pass all trigger properties to the pipeline
72+
// }
73+
}
74+
]
75+
type: 'BlobEventsTrigger'
76+
typeProperties: {
77+
blobPathBeginsWith: '/${storageContainer}/blobs/${storagePathStartsWith}'
78+
blobPathEndsWith: storagePathEndsWith
79+
ignoreEmptyBlobs: true
80+
scope: storageAccount.id
81+
events: [
82+
'Microsoft.Storage.BlobCreated'
83+
]
84+
}
85+
}
86+
}
87+
}
88+
89+
90+
//==============================================================================
91+
// Outputs
92+
//==============================================================================
93+
94+
// @description('Fully-qualified event that is triggered when the configured event occurs.')
95+
// output event string = event

0 commit comments

Comments
 (0)