1- import { DataFactoryManagementClient , Factory } from '@azure/arm-datafactory'
1+ import {
2+ DataFactoryManagementClient ,
3+ DataFlowResource ,
4+ DatasetResource ,
5+ Factory ,
6+ IntegrationRuntimeResource ,
7+ LinkedServiceResource ,
8+ PipelineResource ,
9+ TriggerResource ,
10+ } from '@azure/arm-datafactory'
211import { PagedAsyncIterableIterator } from '@azure/core-paging'
312import CloudGraph from '@cloudgraph/sdk'
413
@@ -19,6 +28,198 @@ export interface RawAzureDataFactory
1928 region : string
2029 resourceGroupId : string
2130 Tags : TagMap
31+ pipelines : PipelineResource [ ]
32+ dataFlows : DataFlowResource [ ]
33+ datasets : DatasetResource [ ]
34+ integrationRuntimes : IntegrationRuntimeResource [ ]
35+ linkedServices : LinkedServiceResource [ ]
36+ triggers : TriggerResource [ ]
37+ }
38+
39+ const getPipelines = async ( {
40+ client,
41+ resourceGroupName,
42+ factoryName,
43+ } : {
44+ client : DataFactoryManagementClient
45+ resourceGroupName : string
46+ factoryName : string
47+ } ) : Promise < PipelineResource [ ] > => {
48+ const pipelines : PipelineResource [ ] = [ ]
49+ const pipelinesIterable : PagedAsyncIterableIterator < PipelineResource > =
50+ client . pipelines . listByFactory ( resourceGroupName , factoryName )
51+
52+ await tryCatchWrapper (
53+ async ( ) => {
54+ for await ( const pipeline of pipelinesIterable ) {
55+ if ( pipeline ) {
56+ pipelines . push ( pipeline )
57+ }
58+ }
59+ } ,
60+ {
61+ service : serviceName ,
62+ client,
63+ scope : 'pipelines' ,
64+ operation : 'listByFactory' ,
65+ }
66+ )
67+ return pipelines
68+ }
69+
70+ const getDataFlows = async ( {
71+ client,
72+ resourceGroupName,
73+ factoryName,
74+ } : {
75+ client : DataFactoryManagementClient
76+ resourceGroupName : string
77+ factoryName : string
78+ } ) : Promise < DataFlowResource [ ] > => {
79+ const flows : DataFlowResource [ ] = [ ]
80+ const flowsIterable : PagedAsyncIterableIterator < DataFlowResource > =
81+ client . dataFlows . listByFactory ( resourceGroupName , factoryName )
82+
83+ await tryCatchWrapper (
84+ async ( ) => {
85+ for await ( const flow of flowsIterable ) {
86+ if ( flow ) {
87+ flows . push ( flow )
88+ }
89+ }
90+ } ,
91+ {
92+ service : serviceName ,
93+ client,
94+ scope : 'flows' ,
95+ operation : 'listByFactory' ,
96+ }
97+ )
98+ return flows
99+ }
100+
101+ const getDatasets = async ( {
102+ client,
103+ resourceGroupName,
104+ factoryName,
105+ } : {
106+ client : DataFactoryManagementClient
107+ resourceGroupName : string
108+ factoryName : string
109+ } ) : Promise < DatasetResource [ ] > => {
110+ const datasets : DatasetResource [ ] = [ ]
111+ const datasetsIterable : PagedAsyncIterableIterator < DatasetResource > =
112+ client . datasets . listByFactory ( resourceGroupName , factoryName )
113+
114+ await tryCatchWrapper (
115+ async ( ) => {
116+ for await ( const dataset of datasetsIterable ) {
117+ if ( dataset ) {
118+ datasets . push ( dataset )
119+ }
120+ }
121+ } ,
122+ {
123+ service : serviceName ,
124+ client,
125+ scope : 'datasets' ,
126+ operation : 'listByFactory' ,
127+ }
128+ )
129+ return datasets
130+ }
131+
132+ const getIntegrationRuntimes = async ( {
133+ client,
134+ resourceGroupName,
135+ factoryName,
136+ } : {
137+ client : DataFactoryManagementClient
138+ resourceGroupName : string
139+ factoryName : string
140+ } ) : Promise < IntegrationRuntimeResource [ ] > => {
141+ const runtimes : IntegrationRuntimeResource [ ] = [ ]
142+ const runtimesIterable : PagedAsyncIterableIterator < IntegrationRuntimeResource > =
143+ client . integrationRuntimes . listByFactory ( resourceGroupName , factoryName )
144+
145+ await tryCatchWrapper (
146+ async ( ) => {
147+ for await ( const runtime of runtimesIterable ) {
148+ if ( runtime ) {
149+ runtimes . push ( runtime )
150+ }
151+ }
152+ } ,
153+ {
154+ service : serviceName ,
155+ client,
156+ scope : 'integrationRuntimes' ,
157+ operation : 'listByFactory' ,
158+ }
159+ )
160+ return runtimes
161+ }
162+
163+ const getLinkedServices = async ( {
164+ client,
165+ resourceGroupName,
166+ factoryName,
167+ } : {
168+ client : DataFactoryManagementClient
169+ resourceGroupName : string
170+ factoryName : string
171+ } ) : Promise < LinkedServiceResource [ ] > => {
172+ const linkedServices : LinkedServiceResource [ ] = [ ]
173+ const linkedServicesIterable : PagedAsyncIterableIterator < LinkedServiceResource > =
174+ client . linkedServices . listByFactory ( resourceGroupName , factoryName )
175+
176+ await tryCatchWrapper (
177+ async ( ) => {
178+ for await ( const linkedService of linkedServicesIterable ) {
179+ if ( linkedService ) {
180+ linkedServices . push ( linkedService )
181+ }
182+ }
183+ } ,
184+ {
185+ service : serviceName ,
186+ client,
187+ scope : 'linkedServices' ,
188+ operation : 'listByFactory' ,
189+ }
190+ )
191+ return linkedServices
192+ }
193+
194+ const getTriggers = async ( {
195+ client,
196+ resourceGroupName,
197+ factoryName,
198+ } : {
199+ client : DataFactoryManagementClient
200+ resourceGroupName : string
201+ factoryName : string
202+ } ) : Promise < TriggerResource [ ] > => {
203+ const triggers : TriggerResource [ ] = [ ]
204+ const triggersIterable : PagedAsyncIterableIterator < TriggerResource > =
205+ client . triggers . listByFactory ( resourceGroupName , factoryName )
206+
207+ await tryCatchWrapper (
208+ async ( ) => {
209+ for await ( const trigger of triggersIterable ) {
210+ if ( trigger ) {
211+ triggers . push ( trigger )
212+ }
213+ }
214+ } ,
215+ {
216+ service : serviceName ,
217+ client,
218+ scope : 'triggers' ,
219+ operation : 'listByFactory' ,
220+ }
221+ )
222+ return triggers
22223}
23224
24225export default async ( {
@@ -49,10 +250,46 @@ export default async ({
49250 if ( factory ) {
50251 const { location, tags, ...restOfFactory } = factory
51252 const resourceGroupId = getResourceGroupFromEntity ( restOfFactory )
253+ const pipelines = await getPipelines ( {
254+ client,
255+ resourceGroupName : resourceGroupId ,
256+ factoryName : factory . name ,
257+ } )
258+ const dataFlows = await getDataFlows ( {
259+ client,
260+ resourceGroupName : resourceGroupId ,
261+ factoryName : factory . name ,
262+ } )
263+ const datasets = await getDatasets ( {
264+ client,
265+ resourceGroupName : resourceGroupId ,
266+ factoryName : factory . name ,
267+ } )
268+ const integrationRuntimes = await getIntegrationRuntimes ( {
269+ client,
270+ resourceGroupName : resourceGroupId ,
271+ factoryName : factory . name ,
272+ } )
273+ const linkedServices = await getLinkedServices ( {
274+ client,
275+ resourceGroupName : resourceGroupId ,
276+ factoryName : factory . name ,
277+ } )
278+ const triggers = await getTriggers ( {
279+ client,
280+ resourceGroupName : resourceGroupId ,
281+ factoryName : factory . name ,
282+ } )
52283 factories . push ( {
53284 region : lowerCaseLocation ( location ) ,
54285 Tags : tags || { } ,
55286 resourceGroupId,
287+ pipelines,
288+ dataFlows,
289+ datasets,
290+ integrationRuntimes,
291+ linkedServices,
292+ triggers,
56293 ...restOfFactory ,
57294 } )
58295 }
@@ -68,7 +305,7 @@ export default async ({
68305 logger . debug ( lt . foundDataFactory ( factories . length ) )
69306
70307 const result : { [ property : string ] : RawAzureDataFactory [ ] } = { }
71- factories . map ( ( { region, tags, ...rest } ) => {
308+ factories . forEach ( ( { region, tags, ...rest } ) => {
72309 if ( regions . includes ( region ) ) {
73310 if ( ! result [ region ] ) {
74311 result [ region ] = [ ]
0 commit comments