Skip to content

Commit ff93fef

Browse files
authored
Merge branch 'Azure:main' into main
2 parents 9b5740a + 1dce16e commit ff93fef

File tree

102 files changed

+16492
-13338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+16492
-13338
lines changed

.DS_Store

8 KB
Binary file not shown.

Connector/FindImpactedObjects.ps1

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
# Make sure run PowerShell cmd with administrator
2+
3+
param (
4+
[Parameter(Mandatory = $true)]
5+
[string]$SubscriptionId,
6+
7+
[Parameter(Mandatory = $true)]
8+
[string]$TenantId
9+
)
10+
11+
# Disable warning for get access token
12+
function Get-PlainAccessToken {
13+
$prev = $WarningPreference
14+
$WarningPreference = 'SilentlyContinue'
15+
$token = (Get-AzAccessToken).Token
16+
$WarningPreference = $prev
17+
18+
$plainToken = [Runtime.InteropServices.Marshal]::PtrToStringBSTR(
19+
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($token)
20+
)
21+
return $plainToken
22+
}
23+
24+
function Get-AllLinkedServices {
25+
param (
26+
[string]$Uri
27+
)
28+
29+
$allLinkedServices = New-Object System.Collections.ArrayList
30+
$nextUri = $Uri
31+
$token = Get-PlainAccessToken
32+
33+
$headers = @{
34+
Authorization = "Bearer $token"
35+
"Content-Type" = "application/json"
36+
}
37+
38+
while ($nextUri) {
39+
try {
40+
$response = Invoke-RestMethod -Method GET -Uri $nextUri -Headers $headers
41+
}
42+
catch {
43+
Write-Warning "Failed to fetch: $nextUri"
44+
break
45+
}
46+
47+
if ($response.value -ne $null -and $response.value.Count -gt 0) {
48+
#Write-Host " Retrieved $($response.value.Count) linked services"
49+
foreach ($item in $response.value) {
50+
[void]$allLinkedServices.Add($item)
51+
}
52+
}
53+
else {
54+
#Write-Warning "No linked services found in current batch."
55+
break
56+
}
57+
58+
$nextUri = if ($response.PSObject.Properties.Name -contains 'nextLink') { $response.nextLink } else { $null }
59+
60+
# # Optional: delay to avoid throttling
61+
# Start-Sleep -Milliseconds 300
62+
}
63+
64+
return $allLinkedServices
65+
}
66+
67+
function Print-Result {
68+
param (
69+
[string]$dfName,
70+
[string]$lsName,
71+
[string]$lsType,
72+
[string]$outputFileName
73+
)
74+
Write-Host "$dfName, $lsName, $lsType"
75+
76+
77+
# Output it to a file
78+
$data = [PSCustomObject]@{
79+
DataFactoryName = $dfName
80+
LinkedServiceName = $lsName
81+
Type = $lsType
82+
}
83+
$data | Export-Csv -Path $outputFileName -NoTypeInformation -Append
84+
}
85+
86+
# Step 1: Install/Update Required Modules
87+
Write-Host "Checking for Az modules..." -ForegroundColor Cyan
88+
Install-Module -Name Az.DataFactory -Force -AllowClobber
89+
Import-Module Az.DataFactory
90+
# If you hit incompatible version, try Install-Module -Name Az.Accounts -RequiredVersion <your version>, and reopen the cmd
91+
92+
# Show the version in use
93+
$module = Get-Module -Name Az.DataFactory
94+
if ($module) {
95+
Write-Host "Az.DataFactory version in use: $($module.Version)" -ForegroundColor Green
96+
} else {
97+
Write-Host "Az.DataFactory module not loaded." -ForegroundColor Red
98+
}
99+
100+
# Step 2: Log into Azure
101+
Write-Host "Connecting to Azure..." -ForegroundColor Cyan
102+
Connect-AzAccount -ErrorAction Stop -subscription $SubscriptionId -tenantId $TenantId
103+
104+
# Step 3: Get all Data Factories in the subscription
105+
Write-Host "Retrieving Data Factories..." -ForegroundColor Cyan
106+
$dataFactories = Get-AzDataFactoryV2
107+
108+
if ($dataFactories.Count -eq 0) {
109+
Write-Host "No Data Factories found in subscription $SubscriptionId"
110+
exit
111+
}
112+
113+
#Step 4: Found legacy linked services, we can extend this list
114+
$LegacyV1LSTypes = @(
115+
# Disabled:
116+
"AmazonMWS",
117+
# End of support:
118+
"Zoho",
119+
"SalesforceMarketingCloud",
120+
"Phoenix",
121+
"PayPal",
122+
"OracleServiceCloud",
123+
"Responsys",
124+
"Eloqua",
125+
"Marketo",
126+
"Magento",
127+
"HBase",
128+
"Drill",
129+
"Couchbase",
130+
"Concur",
131+
"AzureMariaDB",
132+
"GoogleBigQuery",
133+
"PostgreSql",
134+
"ServiceNow",
135+
"Snowflake",
136+
"Salesforce",
137+
"SalesforceServiceCloud"
138+
)
139+
140+
$LegacyV1VersionLSTypes = @(
141+
# End of support
142+
"MySql",
143+
"MariaDB",
144+
# V2 GA
145+
"Vertica",
146+
"Oracle",
147+
"Greenplum",
148+
"AzurePostgreSql",
149+
"Teradata",
150+
"AmazonRdsForOracle",
151+
"Hive",
152+
"Impala",
153+
"Spark",
154+
"Presto",
155+
"Cassandra",
156+
# V2 Preview
157+
"QuickBooks"
158+
)
159+
160+
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
161+
$filename = "output_$timestamp.csv"
162+
163+
foreach ($df in $dataFactories) {
164+
$resourceGroup = $df.ResourceGroupName
165+
$dataFactoryName = $df.DataFactoryName
166+
167+
$uri = "https://management.azure.com/subscriptions/$SubscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.DataFactory/factories/$dataFactoryName/linkedservices?api-version=2018-06-01"
168+
169+
try {
170+
$response = Invoke-AzRestMethod -Method GET -Uri $uri
171+
$linkedServices = Get-AllLinkedServices -Uri $uri
172+
173+
174+
if ($linkedServices.Count -eq 0) {
175+
continue
176+
}
177+
178+
foreach ($ls in $linkedServices) {
179+
$name = $ls.name
180+
$type = $ls.properties.type
181+
$version = $ls.properties.version
182+
$typeProps = $ls.properties.typeProperties | ConvertTo-Json -Depth 10 | ConvertFrom-Json
183+
184+
if ($LegacyV1LSTypes -contains $type) {
185+
Print-Result -dfName $dataFactoryName -lsName $name -lsType $type -outputFileName $filename
186+
}
187+
188+
# Find v1 versions.
189+
if ($LegacyV1VersionLSTypes -contains $type) {
190+
if ($version -ne "2.0") { # Skip version 2.0, it must be non-legacy
191+
switch ($type) { # MySql and MariaDB are not following the version design, hence, need some custom logic here
192+
{($_ -eq "MariaDB") -or ($_ -eq "MySql")} {
193+
$connectionString = $typeProps.connectionString
194+
if (-not [string]::IsNullOrEmpty($connectionString)) {
195+
Print-Result -dfName $dataFactoryName -lsName $name -lsType $type -outputFileName $filename
196+
}
197+
break
198+
}
199+
default {
200+
Print-Result -dfName $dataFactoryName -lsName $name -lsType $type -outputFileName $filename
201+
break
202+
}
203+
}
204+
}
205+
}
206+
}
207+
} catch {
208+
Write-Host "Failed to fetch linked services for $dataFactoryName" -ForegroundColor Red
209+
}
210+
}

0 commit comments

Comments
 (0)