-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from SQLPlayer/config-json
Config in JSON & Support of Global Parameters
- Loading branch information
Showing
25 changed files
with
429 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ConfigLine { | ||
[string] $type = "" | ||
[string] $name = "" | ||
[string] $path = "" | ||
[string] $value = "" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
function Read-JsonConfigFile { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory)] [string] $Path, | ||
[Parameter(Mandatory)] [Adf] $adf | ||
) | ||
|
||
Write-Debug "BEGIN: Read-JsonConfigFile(path=$path)" | ||
$configFileName = $Path | ||
|
||
Write-Debug "Testing config file..." | ||
Test-Path -Path $configFileName -PathType Leaf | Out-Null | ||
|
||
#$configFileName = "X:\!WORK\GitHub\!SQLPlayer\azure.datafactory.tools\test\BigFactorySample2\deployment\config-c100.json" | ||
$configtxt = Get-Content $configFileName -Raw | Out-String | ||
$json = ConvertFrom-Json $configtxt | ||
|
||
# Creating CSV-like an object | ||
[System.Collections.ArrayList] $config = @{} | ||
|
||
Set-StrictMode -Version 1.0 # Due to field 'action' which may not exist | ||
$json.psobject.properties.name | ForEach-Object { | ||
$name = $_ | ||
$o = $json.($name) | ||
$o | ForEach-Object { | ||
$dst = $adf.AllObjects() | Where-Object { $_.Name -eq $name } | Select-Object -First 1 | ||
if ($null -ne $dst) { | ||
$cl = New-Object -TypeName ConfigLine | ||
$cl.name = $name | ||
$cl.type = $dst.Type | ||
$cl.value = $_.value | ||
$cl.path = $_.name | ||
if ($_.action -eq "remove") { $cl.path = "-$($cl.path)" } | ||
if ($_.action -eq "add") { $cl.path = "+$($cl.path)" } | ||
$null = $config.Add($cl) | ||
} else { | ||
Write-Error "Object [$name] could not be found." | ||
} | ||
} | ||
} | ||
|
||
# Expanding string (replace Environment Variables with values) | ||
$config | ForEach-Object { | ||
$_.value = $ExecutionContext.InvokeCommand.ExpandString($_.value); | ||
} | ||
|
||
return $config.ToArray() | ||
|
||
Write-Debug "END: Read-JsonConfigFile" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
function Update-GlobalParameters { | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory)] [Adf] $adf, | ||
[Parameter(Mandatory)] $targetAdf | ||
) | ||
|
||
Write-Debug "BEGIN: Update-GlobalParameters" | ||
|
||
if ($adf.GlobalFactory.body.Length -gt 0) | ||
{ | ||
$newGlobalParameters = New-Object 'system.collections.generic.dictionary[string,Microsoft.Azure.Management.DataFactory.Models.GlobalParameterSpecification]' | ||
Write-Verbose "Parsing JSON..." | ||
$globalFactoryObject = [Newtonsoft.Json.Linq.JObject]::Parse($adf.GlobalFactory.body) | ||
#$globalParametersObject = $globalFactoryObject.properties.globalParameters | ||
|
||
Write-Host "Adding global parameter..." | ||
foreach ($p in $adf.GlobalFactory.GlobalParameters.properties.globalParameters.PSObject.Properties) | ||
{ | ||
# $p.Name | ||
# $p.Value.type | ||
# $p.Value.value | ||
$gpspec = New-Object 'Microsoft.Azure.Management.DataFactory.Models.GlobalParameterSpecification' | ||
$gpspec.Type = $p.Value.type | ||
$gpspec.Value = $p.Value.value | ||
$globalParameterValue = $gpspec | ||
$newGlobalParameters.Add($p.Name, $globalParameterValue) | ||
} | ||
$targetAdf.GlobalParameters = $newGlobalParameters | ||
|
||
# Write-Host "--- newGlobalParameters ---" | ||
#$newGlobalParameters.Values | Out-Host | ||
|
||
Write-Verbose "Updating $($newGlobalParameters.Count) global parameters..." | ||
Set-AzDataFactoryV2 -InputObject $targetAdf -Force | Out-Null | ||
Write-Host "Update of $($newGlobalParameters.Count) global parameters complete." | ||
} | ||
|
||
Write-Debug "END: Update-GlobalParameters" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.