public/Get-AdfFromService.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<#
.SYNOPSIS
Loads all objects from Azure Data Factory instance (service).
 
.DESCRIPTION
Loads all objects from Azure Data Factory instance (service).
 
.PARAMETER FactoryName
Name of Azure Data Factory service to be loaded.
 
.PARAMETER ResourceGroupName
Resource Group Name of ADF service to be loaded.
 
.EXAMPLE
$ResourceGroupName = 'rg-devops-factory'
$DataFactoryName = "SQLPlayerDemo"
$adfIns = Get-AdfFromService -FactoryName "$DataFactoryName" -ResourceGroupName "$ResourceGroupName"
$adfIns.AllObjects()
 
.LINK
Online version: https://github.com/SQLPlayer/azure.datafactory.tools/
#>

function Get-AdfFromService {
    [CmdletBinding()]
    param (
        [parameter(Mandatory = $true)] [String] $FactoryName,
        [parameter(Mandatory = $true)] [String] $ResourceGroupName
    )
    Write-Debug "BEGIN: Get-AdfFromService(FactoryName=$FactoryName, ResourceGroupName=$ResourceGroupName)"

    $adf = New-Object -TypeName AdfInstance
    $adf.Name = $FactoryName
    $adf.ResourceGroupName = $ResourceGroupName

    $adfi = Get-AzDataFactoryV2 -ResourceGroupName "$ResourceGroupName" -Name "$DataFactoryName"
    Write-Host ("Azure Data Factory (instance) loaded." -f $adf.DataSets.Count)
    $adf.Id = $adfi.DataFactoryId
    $adf.Location = $adfi.Location

    $adf.DataSets = Get-AzDataFactoryV2Dataset -ResourceGroupName "$ResourceGroupName" -DataFactoryName "$DataFactoryName" | ToArray
    Write-Host ("DataSets: {0} object(s) loaded." -f $adf.DataSets.Count)
    $adf.IntegrationRuntimes = Get-AzDataFactoryV2IntegrationRuntime -ResourceGroupName "$ResourceGroupName" -DataFactoryName "$DataFactoryName" | ToArray
    Write-Host ("IntegrationRuntimes: {0} object(s) loaded." -f $adf.IntegrationRuntimes.Count)
    $adf.LinkedServices = Get-AzDataFactoryV2LinkedService -ResourceGroupName "$ResourceGroupName" -DataFactoryName "$DataFactoryName" | ToArray
    Write-Host ("LinkedServices: {0} object(s) loaded." -f $adf.LinkedServices.Count)
    $adf.Pipelines = Get-AzDataFactoryV2Pipeline -ResourceGroupName "$ResourceGroupName" -DataFactoryName "$DataFactoryName" | ToArray
    Write-Host ("Pipelines: {0} object(s) loaded." -f $adf.Pipelines.Count)
    $adf.DataFlows = Get-AzDataFactoryV2DataFlow -ResourceGroupName "$ResourceGroupName" -DataFactoryName "$DataFactoryName" | ToArray
    Write-Host ("DataFlows: {0} object(s) loaded." -f $adf.DataFlows.Count)
    $adf.Triggers = Get-AzDataFactoryV2Trigger -ResourceGroupName "$ResourceGroupName" -DataFactoryName "$DataFactoryName" | ToArray
    Write-Host ("Triggers: {0} object(s) loaded." -f $adf.Triggers.Count)

    Write-Debug "END: Get-AdfFromService()"
    return $adf
}