SamplesV2/ContinuousIntegrationAndDelivery/GlobalParametersUpdateScript.ps1 (25 lines of code) (raw):
param
(
[parameter(Mandatory = $true)] [String] $globalParametersFilePath,
[parameter(Mandatory = $true)] [String] $resourceGroupName,
[parameter(Mandatory = $true)] [String] $dataFactoryName
)
Import-Module Az.DataFactory
$newGlobalParameters = New-Object 'system.collections.generic.dictionary[string,Microsoft.Azure.Management.DataFactory.Models.GlobalParameterSpecification]'
Write-Warning "This method of deploying global parameters using PS script is not recommended. Please use the new mechanism as per this document https://learn.microsoft.com/en-us/azure/data-factory/author-global-parameters#cicd"
Write-Host "Getting global parameters JSON from: " $globalParametersFilePath
$globalParametersJson = Get-Content $globalParametersFilePath
Write-Host "Parsing JSON..."
$globalParametersObject = [Newtonsoft.Json.Linq.JObject]::Parse($globalParametersJson)
foreach ($gp in $globalParametersObject.GetEnumerator()) {
Write-Host "Adding global parameter:" $gp.Key
$globalParameterValue = $gp.Value.ToObject([Microsoft.Azure.Management.DataFactory.Models.GlobalParameterSpecification])
$newGlobalParameters.Add($gp.Key, $globalParameterValue)
}
$dataFactory = Get-AzDataFactoryV2 -ResourceGroupName $resourceGroupName -Name $dataFactoryName
$dataFactory.GlobalParameters = $newGlobalParameters
Write-Host "Updating" $newGlobalParameters.Count "global parameters."
if ($dataFactory.RepoConfiguration -and ($dataFactory.RepoConfiguration.GetType().Name -eq 'FactoryGitHubConfiguration') -and (-not $dataFactory.RepoConfiguration.HostName)) {
$dataFactory.RepoConfiguration.HostName = 'https://github.com'
}
Set-AzDataFactoryV2 -InputObject $dataFactory -Force