直接回答你的问题:
不,没有单独的 DEV ADF,旧版和新版之间的唯一区别是您不再需要从协作分支手动单击发布。它的工作方式是,您现在拥有一个构建管道,只要协作分支有更新(通过 PR)就会触发该构建管道,一旦构建验证并生成工件,就会有一个发布管道将 ARM 模板部署到您的 DEV数据工厂。
以下是屏幕截图显示:
1、将此 package.json 文件添加到您的协作分支
{
"scripts":{
"build":"node node_modules/@microsoft/azure-data-factory-utilities/lib/index"
},
"dependencies":{
"@microsoft/azure-data-factory-utilities":"^0.1.5"
}
}
就像我一样:
2、创建 yaml 构建管道并编辑下面脚本中的参数
# Sample YAML file to validate and export an ARM template into a build artifact
# Requires a package.json file located in the target repository
trigger:
- main #collaboration branch
pool:
vmImage: 'ubuntu-latest'
steps:
# Installs Node and the npm packages saved in your package.json file in the build
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@1
inputs:
command: 'install'
workingDir: '$(Build.Repository.LocalPath)/<folder-of-the-package.json-file>' #replace with the package.json folder
verbose: true
displayName: 'Install npm package'
# Validates all of the Data Factory resources in the repository. You'll get the same validation errors as when "Validate All" is selected.
# Enter the appropriate subscription and name for the source factory.
- task: Npm@1
inputs:
command: 'custom'
workingDir: '$(Build.Repository.LocalPath)/<folder-of-the-package.json-file>' #replace with the package.json folder
customCommand: 'run build validate $(Build.Repository.LocalPath) /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testResourceGroup/providers/Microsoft.DataFactory/factories/yourFactoryName'
displayName: 'Validate'
# Validate and then generate the ARM template into the destination folder, which is the same as selecting "Publish" from the UX.
# The ARM template generated isn't published to the live version of the factory. Deployment should be done by using a CI/CD pipeline.
- task: Npm@1
inputs:
command: 'custom'
workingDir: '$(Build.Repository.LocalPath)/<folder-of-the-package.json-file>' #replace with the package.json folder
customCommand: 'run build export $(Build.Repository.LocalPath) /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testResourceGroup/providers/Microsoft.DataFactory/factories/yourFactoryName "ArmTemplate"'
displayName: 'Validate and Generate ARM template'
# Publish the artifact to be used as a source for a release pipeline.
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.Repository.LocalPath)/<folder-of-the-package.json-file>/ArmTemplate' #replace with the package.json folder
artifact: 'ArmTemplates'
publishLocation: 'pipeline'
每次协作分支发生更改时都应该运行此构建。
3、创建将使用构建工件(ARM 模板和参数文件)部署到 DEV ADF 的发布管道
任务详情:
不要忘记在 ADF 构建上设置持续部署触发器。
这就是全部,不再需要点击那个讨厌的发布按钮,而是你必须手动输入覆盖参数......你赢得了一些,你失去了一些......
EDIT:
我发现,如果您的 ARM 模板中包含全局参数,如果指定了这些参数,那么当您部署到 DEV ADF 时,它会断开您的工厂与 Azure DevOps Git 的连接。为了避免这种情况,您可以通过 PostDeploy powershell 脚本添加全局参数。
以下是执行此操作的步骤:
1.确保在 Azure 数据工厂全局参数页面中取消选中“包含在 ARM 模板中”:
您需要在协作分支中为 ADF 的每个环境保存一个 globalParameters json 文件。该文件将在 Powershell 脚本中使用,以确保 globalParameter 存在于您的 ADF 中。
2.创建 Powershell 脚本文件并将其保存在协作分支中,以便可以通过 Az Powershell 任务在版本中使用它。
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)
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."
Set-AzDataFactoryV2 -InputObject $dataFactory -Force
3.确保发布管道中有一个 Az Powershell 任务,用于使用给定参数运行 PostDeployment powershell 脚本。
如果所有这些都设置正确,那么您应该拥有一个为 ADF 构建的完全自动化的 CI/CD 流程(并且它不应该使您与 Git 断开连接)
如果我可以提供任何其他帮助,请告诉我!