我认为您可能会使用 nuget 包等使事情复杂化。
这是我用于 PostDeploy 的简单 Powershell 脚本,用于指定要启用的触发器:
param
(
[parameter(Mandatory = $true)] [String] $globalParametersFilePath,
[parameter(Mandatory = $true)] [String] $resourceGroupName,
[parameter(Mandatory = $true)] [String] $dataFactoryName
)
$triggersADF = @(
'Trig_CMSFileDeployment_Prod',
'Trig_StorageEvent_stccokops_blob-cmsfiledeploy-configfiles',
'Trig_CMSFileDeployment_Prod'
)
}
$triggersADF | ForEach-Object { Start-AzDataFactoryV2Trigger -ResourceGroupName $resourceGroupName -DataFactoryName $dataFactoryName -Name $_ -Force }
这也是我的脚本参数:
-resourceGroupName "rg-ccok-ops-$(Environment)-001"
-dataFactoryName "adf-ccok-opscmsfiledeploy-$(Environment)-001"
这是我的发布管道中的 Az Powershell 任务的屏幕截图(有一个额外的脚本 arg 您不需要,因为我必须为此示例修改一些内容)
如果您只想启用 ADF 中的所有触发器,您可以使用此代码(而不是单独指定每个触发器):
param(
[parameter(Mandatory = $true)] [string]$ResourceGroupName,
[parameter(Mandatory = $true)] [string]$dataFactoryName,
)
if ([string]::IsNullOrEmpty($(Get-AzureRmContext).Account)) {
Add-AzureRmAccount
}
$ADF_Triggers = Get-AzureRmDataFactoryV2Trigger -ResourceGroupName $ResourceGroupName -DataFactoryName $dataFactoryName -ErrorVariable notPresent -ErrorAction SilentlyContinue
Write-Host $ADF_Triggers.Name
if ($notPresent) {
Write-Host "Trigger does not exist. Nothing to enable!"
}
else {
$ADF_Triggers | ForEach-Object {
Write-Host "Enabling Pipeline Trigger $($_.name)"
Start-AzureRmDataFactoryV2Trigger -ResourceGroupName $ResourceGroupName -DataFactoryName $dataFactoryName -Name $_.name -Force
}
}
感谢https://bzzzt.io/post/2018-11/2018-11-08-adf/部分代码