【问题标题】:How to delete Global Parameters using Powershell command如何使用 Powershell 命令删除全局参数
【发布时间】:2022-06-27 00:27:15
【问题描述】:

我在 DEV Azure 数据工厂中创建了许多全局参数,这些参数用于许多管道。我已使用 ARM 模板将这些全局参数部署到我们的 QA 环境中。 现在我从 Dev 环境中删除了一些参数,当我重新部署 ARM 模板时,这些参数并没有从 QA 环境中删除。

我没有找到任何其他方式从 QA 环境中删除,因为我们在 QA 中没有删除权限。 你能建议接下来的步骤是什么吗?我正在寻找一种 powershell 命令方式来删除这些参数。

【问题讨论】:

    标签: azure-data-factory


    【解决方案1】:
    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-Host "Getting global parameters JSON from: " $globalParametersFilePath
    $globalParametersJson = Get-Content $globalParametersFilePath
    
    Write-Host "Parsing JSON..."
    $globalParametersObject = [Newtonsoft.Json.Linq.JObject]::Parse($globalParametersJson)
    
    # $gp in $factoryFileObject.properties.globalParameters.GetEnumerator()) 
    # may  be used in case you use non-standard location for global parameters. It is not recommended. 
    foreach ($gp in $globalParametersObject.GetEnumerator()) {
        Write-Host "Removing global parameter:" $gp.Key
        $globalParameterValue = $gp.Value.ToObject([Microsoft.Azure.Management.DataFactory.Models.GlobalParameterSpecification])
        $newGlobalParameters.Remove($gp.Key)
    }
    
    $dataFactory = Get-AzDataFactoryV2 -ResourceGroupName $resourceGroupName -Name $dataFactoryName
    $dataFactory.GlobalParameters = $newGlobalParameters
    
    Write-Host "Updating" $newGlobalParameters.Count "global parameters."
    
    Set-AzDataFactoryV2 -InputObject $dataFactory -Force
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-21
      • 1970-01-01
      • 2022-06-15
      • 2012-03-06
      • 2015-11-13
      • 2021-09-11
      • 1970-01-01
      相关资源
      最近更新 更多