具有改进的 CI/CD 的 Azure 数据工厂部署

2024-03-16

我正在关注此处发布的为 ADF 设置的新推荐 ci/cd:https://learn.microsoft.com/en-us/azure/data-factory/continuous-integration-deployment-improvements https://learn.microsoft.com/en-us/azure/data-factory/continuous-integration-deployment-improvements

我不清楚的一个部分是,您现在是否需要管道发布到的额外“开发”ADF。

在旧模型下,您将在链接到 git 的 ADF 中完成开发工作,执行拉取请求以合并回协作分支,然后单击发布。这将发布到同一 ADF 中的 adf_publish 分支。

使用新模型时,您是否有一个链接到 git 的 ADF,您可以像以前一样进行开发工作 - 但管道是否部署到一个新的单独的“dev”ADF(未链接到 git)?


直接回答你的问题:

不,没有单独的 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 断开连接)

如果我可以提供任何其他帮助,请告诉我!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

具有改进的 CI/CD 的 Azure 数据工厂部署 的相关文章

随机推荐

  • 我可以在 schema.org 丰富摘要的 Span 标记中使用多个 ItemProps 吗?

    假设我想向以下句子添加丰富的摘要 我在纽约生活和工作 由于纽约既是我的居住地 也是我工作的城市 理论上我希望使用 schema org 标准来标记该行 div I live and work in span New York span di
  • 预先输入下拉列表中的全局页脚

    我有一个包含 2 个类别的预输入菜单 但在这些类别下我需要一个按钮 如何添加此全局页脚 以便在缺少第二个类别时可用 我所做的是在每个数据集中添加一个页脚 但使用 CSS 隐藏除最后一个之外的所有数据集 代码如下 search query t
  • 如何更改 selected.js 中警报的语言?

    When you type in an unavailable option in the multiple select box in chosen js it will generate the output No results ma
  • 锁定整个数据库?

    我有非常奇怪的用户需求 我试图向他们解释有更好的方法来支持他们的业务流程 但他们不想听 我很想走开 但我首先想看看是否还有其他方法 有什么方法可以锁定整个数据库而不是行锁或表锁 我知道我也许可以将数据库置于单用户模式 但这意味着一次只有一个
  • Maven Surefire:无法分叉并行测试执行

    使用 Maven Surefire 我无法分叉并行测试执行 也就是说 我的每个测试用例都必须在单独的 JVM 中运行 因此需要分叉 此外 我希望我的测试用例并行运行 第一部分工作没有问题 我能够在自己的 JVM 中运行每个测试用例 然而 第
  • 如何在不实际构建东西的情况下使 gradle 下载依赖项

    到了新的环境gradle build需要相当长的时间 因为必须下载所有依赖项 有没有办法只下载依赖项以加快后续构建的速度 这样我们就可以预先填充 CI 构建环境 编辑 针对 Gradle 6 进行了更新 一些注意事项 这种新方法将 jar
  • dplyr 用动态列进行总结

    我正在尝试对我的 postgres 数据库使用 dplyr 并执行一个简单的函数 如果我直接解析列名 一切都会正常 但是我想动态地执行此操作 即对另一个数据帧中的每个列名进行排序 我遇到的问题是对于前两个计算 我得到了正确的结果 假设第一个
  • 在 Eclipse 中找不到库“libmaliinstr.so”

    请帮我 我的Android应用程序是一个闹钟应用程序 可以在许多Android设备上按时播放 但是在华为荣耀C3等某些设备上播放时 我的代码出现错误 错误是 09 26 18 17 19 119 E linker 23841 load li
  • 导入 Python 模块时 __package__ 为 None

    我想通过以下方式动态导入模块 我创建一个名为 pkg 的文件夹 其结构如下 pkg init py foo py 在头 init py 添加此代码片段 pkgpath os path dirname pkg file for module
  • 移动字符串?

    我正在编写一个用 C 解决凯撒密码的程序 它采用字母表字符串 并在每次循环时将其向左移动 abc yz gt bcd yza 问题出在另一个循环之后 bcd yza gt cde yzaa char temp holds the first
  • 如何在 Gradle 中应用补丁文件?

    我有一个 Gradle 构建脚本 可以成功构建我的项目并编译我需要的所有工件 然而 在某些情况下 我想让其他开发人员可以选择修补某些文件 例如 在其中一个档案中有一个 xml 文件 其中包含有关数据库挂钩的信息 一些开发人员使用其他版本 甚
  • 如何增加 NetBeans IDE 中的字体大小?

    我刚刚买了一台相当大的新显示器 但在阅读编辑器上的文本时遇到了很多困难 我尝试以通常的方式增加字体大小 工具 gt gt 选项 gt gt 字体和颜色 gt gt 单击字体旁边的 按钮 gt gt 然后选择大字体大小 这是结果 点击查看大图
  • 如何将两个 Post/Category 表 MYSQL SELECT 查询合并为一个

    我有两个 MySQL 查询 1 SELECT ID post title post category post perma FROM TBL POSTS WHERE published 1 AND page 0 ORDER BY ID DE
  • jQuery ajax 删除 url 上的整数

    我正在使用这些数据 Pulled from the button that was hit var method document activeElement getAttribute method toUpperCase var url
  • 渐进式 Web 应用程序 - 不尊重屏幕方向

    我的网络应用程序不遵循我的设置中的方向manifest json manifest version 2 version 1 name My App short name My App icons src img myapp launcher
  • 61classes.jar 中存在重复的类,classes.jar 位于何处?

    所以 我的应用程序遇到了一个菜鸟问题 我已经开发了大约两周 突然间 它在启动时开始出现错误 该应用程序快完成了 现在它不再工作了 问题似乎出在classes jar文件夹中 我找不到这个文件夹 因为我是菜鸟 我已经尝试了在该线程上找到的几乎
  • nvarchar(max) 与 NText

    使用的优点和缺点是什么nvarchar max vs NTextSQL Server 中的数据类型 我不需要向后兼容 所以没关系nvarchar max 较旧的 SQL Server 版本不支持 Edit 显然这个问题也适用于TEXT an
  • 为什么在执行 record.inspect 时没有输出 attr_accessor 虚拟属性

    在我的 ListItem Rails 模型中 我有 attr accessor catalyst action actor user id actor full name 我可以在控制器中设置这些变量 并且我确认当记录到达观察者时它们仍然存
  • 在 javascript 中运行 fabcar 示例时出错 [重复]

    这个问题在这里已经有答案了 我正在尝试使用 javascript 链代码运行 fabcar 示例 在实例化链代码时失败并出现以下错误 error could not assemble transaction err proposal res
  • 具有改进的 CI/CD 的 Azure 数据工厂部署

    我正在关注此处发布的为 ADF 设置的新推荐 ci cd https learn microsoft com en us azure data factory continuous integration deployment improv