简体   繁体   English

通过 powershell 或 Azure Devops 管道步骤在 Azure 数据工厂上以编程方式“发布”

[英]“Publish” programmatically on Azure Data Factory through powershell or Azure Devops pipeline step

This question won't have any code because I haven't found any possible way so far but not even a straight no, it's not possible .这个问题不会有任何代码,因为到目前为止我还没有找到任何可能的方法,但甚至没有直接否定,这是不可能的

Azure Data Factory uses adf_publish branch as the official branch on top of the master. Azure 数据工厂使用adf_publish分支作为 master 之上的官方分支。 ADF publishes the definitions of all the pipelines, triggers, linked services, etc to this adf_publish branch when on the GUI the user clicks on Publish .当用户在 GUI 上单击Publish时,ADF 会将所有管道、触发器、链接服务等的定义发布到此 adf_publish 分支。

I need to do this programmatically.我需要以编程方式执行此操作。 I don't want someone to go on the ADF portal itself and click on the Publish button so that the adf_publish branch is updated correctly.我不希望有人访问 ADF 门户本身并单击“发布”按钮,以便正确更新 adf_publish 分支。 I need to know if there is some powershell code (or step in Azure Devops pipeline) that allows me to do this.我需要知道是否有一些 powershell 代码(或 Azure Devops 管道中的步骤)允许我这样做。 Thanks in advance!提前致谢!

UPDATE :更新

After Kevin's answer below I gave it a try with the suggested powershell script and seems succeeding but unfortunately it doesn't seem to do what it's supposed to do.在下面凯文的回答之后,我尝试了建议的 powershell 脚本,似乎成功了,但不幸的是,它似乎没有做它应该做的事情。 Whenever I try to "Publish" from the ADF portal I see that it gathers the changes from the collaboration branch (Master) and tries to merge them in the Adf_Publish branch.每当我尝试从 ADF 门户“发布”时,我都会看到它从协作分支 (Master) 收集更改并尝试将它们合并到 Adf_Publish 分支中。 An example is the pic below listing all the changes that will be merged.一个例子是下面的图片列出了将被合并的所有更改。

在此处输入图片说明

So in theory the powershell script should do the same or that's what I am trying to achieve while instead it seems not doing anything:所以理论上powershell脚本应该做同样的事情,或者这就是我想要实现的,而它似乎没有做任何事情:

在此处输入图片说明

Am I missing something?我错过了什么吗?

You could refer to this ticket in Github.你可以在 Github 上参考这张票

You could install Az.DataFactory and azure.datafactory.tools PowerShell modules, then you could run the Publish-AdfV2FromJson method to publish.您可以安装Az.DataFactoryazure.datafactory.tools PowerShell 模块,然后您可以运行Publish-AdfV2FromJson方法进行发布。

Here is Azure Devops example:这是 Azure DevOps 示例:

variables:
  ResourceGroupName: 'rg-devops-factory'
  DataFactoryName: 'SQLPlayerDemo'
steps:
- powershell: |
   Install-Module Az.DataFactory -MinimumVersion "1.7.0" -Force
   Install-Module -Name "azure.datafactory.tools" -Force
   Import-Module -Name "azure.datafactory.tools" -Force
  displayName: 'PowerShell Script'
steps:
- task: AzurePowerShell@4
  displayName: 'Azure PowerShell script: InlineScript'
  inputs:
    azureSubscription: 'Subscription'
    ScriptType: InlineScript
    Inline: |
     Publish-AdfV2FromJson -RootFolder "$(System.DefaultWorkingDirectory)/_ArtifactName_/" -ResourceGroupName "$(ResourceGroupName)" -DataFactoryName "$(DataFactoryName)" -Location "$(Location)" -Stage "$(Release.EnvironmentName)"

    FailOnStandardError: true
    azurePowerShellVersion: LatestVersion

For more detailed information, you could refer to this introduction document更详细的信息可以参考这个介绍文档

On the other hand, you could use the out of the box task: Publish Azure Data Factory from Deploy Azure Data Factory by SQLPlayer extension .另一方面,您可以使用开箱即用的任务: 通过 SQLPlayer 扩展部署 Azure 数据工厂Publish Azure Data Factory

This is definitely possible and quite an expected requirement in real world case.在现实世界的情况下,这绝对是可能的,并且是相当预期的要求。 Please go through Continuous integration and delivery in Azure Data Factory .请完成Azure 数据工厂中的持续集成和交付 It's too long guide to put it as an answer in short, so you have to read that in details :).将其作为简短的答案的指南太长了,因此您必须详细阅读:)。 Below is just a short quote of the scenario to get you charged:以下只是让您收费的场景的简短引用:

  • A development data factory is created and configured with Azure Repos Git.开发数据工厂是使用 Azure Repos Git 创建和配置的。 All developers should have permission to author Data Factory resources like pipelines and datasets.所有开发人员都应有权创作数据工厂资源,如管道和数据集。

  • A developer creates a feature branch to make a change.开发人员创建一个功能分支来进行更改。 They debug their pipeline runs with their most recent changes.他们使用最近的更改来调试管道运行。 For more information on how to debug a pipeline run, see Iterative development and debugging with Azure Data Factory .有关如何调试管道运行的详细信息,请参阅使用 Azure 数据工厂进行迭代开发和调试

  • After a developer is satisfied with their changes, they create a pull request from their feature branch to the master or collaboration branch to get their changes reviewed by peers.在开发人员对他们的更改感到满意后,他们会创建一个从其功能分支到主分支或协作分支的拉取请求,以便同行审查他们的更改。

  • After a pull request is approved and changes are merged in the master branch, the changes get published to the development factory.在拉取请求获得批准并将更改合并到主分支后,更改将发布到开发工厂。

  • When the team is ready to deploy the changes to a test or UAT (User Acceptance Testing) factory, the team goes to their Azure Pipelines release and deploys the desired version of the development factory to UAT.当团队准备好将更改部署到测试或 UAT(用户验收测试)工厂时,团队会转到他们的 Azure Pipelines 版本并将开发工厂的所需版本部署到 UAT。 This deployment takes place as part of an Azure Pipelines task and uses Resource Manager template parameters to apply the appropriate configuration.此部署作为 Azure Pipelines 任务的一部分进行,并使用资源管理器模板参数来应用适当的配置。

  • After the changes have been verified in the test factory, deploy to the production factory by using the next task of the pipelines release.在测试工厂验证更改后,使用管道发布的下一个任务部署到生产工厂。

To automate the merge from master branch to adf_publish branch in a CI build which runs on master, you can look at Run Git commands in a script .要在 master 上运行的 CI 构建中自动从master分支合并到adf_publish分支,您可以查看在脚本运行 Git 命令 This merges from feature to master, but you will do the opposite.这从功能合并到母版,但您将做相反的事情。

@Tarta, there is plenty of things blended up here. @Tarta,这里融合了很多东西。 I don't want to answer everything here, just let me focus on the tool that you tried to use (azure.datafactory.tools), which means - the first original issue.我不想在这里回答所有问题,让我专注于您尝试使用的工具(azure.datafactory.tools),这意味着 - 第一个原始问题。 Looking at the screenshot of log:查看日志截图:
在此处输入图片说明
There are no objects found by PowerShell module, which likely means you provided the wrong location (folder) to the ADF. PowerShell 模块未找到任何对象,这可能意味着您向 ADF 提供了错误的位置(文件夹)。 Please, read the documentation carefully and make sure you're passing the correct folder while executing Publish-AdfV2FromJson cmdlet.请仔细阅读文档并确保在执行Publish-AdfV2FromJson cmdlet 时传递正确的文件夹。
Also, bear in mind, that the tool deploys ADF from code - master or another collaboration branch you selected.此外,请记住,该工具从代码 - master或您选择的其他协作分支部署 ADF。 The module does NOT care what is going on at adf_publish branch at all.该模块根本不关心adf_publish分支上发生了什么。 The changes into that branch are doing by ADF service when you click PUBLISH, but you don't have to worry about it when you choose to deploy from code by azure.datafactory.tools or DevOps extension .当您单击 PUBLISH 时,对该分支的更改由 ADF 服务执行,但是当您选择通过azure.datafactory.toolsDevOps 扩展从代码部署时,您不必担心。 Additionally, I hope the page I prepared will help you a little bit to understand the whole concept of deploying ADF from code (not from adf_publish): https://sqlplayer.net/adftools/此外,我希望我准备的页面能帮助您了解从代码(而不是来自 adf_publish)部署 ADF 的整个概念: https ://sqlplayer.net/adftools/

Recently, Microsoft has announced that they now support automated Azure Data Factory publish using ADFUtilities NPM (@microsoft/azure-data-factory-utilities) library and Azure DevOps build pipeline.最近,微软宣布他们现在支持使用 ADFUtilities NPM (@microsoft/azure-data-factory-utilities) 库和 Azure DevOps 构建管道自动发布 Azure 数据工厂。

Read more about it at https://azureops.org/articles/automated-azure-data-factory-publish/https://azureops.org/articles/automated-azure-data-factory-publish/阅读更多相关信息在此处输入图片说明

There were improvements made to the Publishing of an Azure Data Factory.对 Azure 数据工厂的发布进行了改进。

Previously you need to manually "Publish" a data factory from the UI which doesn't go well with the concept of automation.以前,您需要从 UI 手动“发布”一个数据工厂,这与自动化概念不符。

Now you can use an ADFUtilities NPM package (preferably in your build pipeline), which will validate all the resources and generate the ARM templates which in turn can be used in the release pipeline for your automated deployments.现在您可以使用ADFUtilities NPM 包(最好在您的构建管道中),它将验证所有资源并生成 ARM 模板,这些模板又可以在发布管道中用于您的自动化部署。 Refer to the below link for the complete details and steps to configure the same.有关完整的详细信息和配置步骤,请参阅以下链接。

https://docs.microsoft.com/en-us/azure/data-factory/continuous-integration-deployment-improvements https://docs.microsoft.com/en-us/azure/data-factory/continuous-integration-deployment-improvements

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法发布Azure数据工厂管道更改 - Unable to publish Azure Data factory Pipeline changes 如何在 Azure DevOps 中等待 Azure 数据工厂管道完成? - How to wait for Azure Data Factory pipeline to complete in Azure DevOps? 是否可以在 Azure 数据工厂的 Azure DevOps 中创建构建管道 - Is it possible to create build pipeline in Azure DevOps for Azure Data factory 如何使用 .NET 数据工厂 ZF20E3C5E54C0893D36 启用 DeVOPS GIT 存储库在 Azure 数据工厂中发布管道? - How to publish pipeline in Azure Data Factory enabled with DeVOPS GIT repo using .NET Data Factory SDK (C# )? 使用PowerShell进行Azure数据工厂管道部署 - Azure Data Factory Pipeline deployment with PowerShell 如何使用PowerShell(Azure Automation)触发Azure Data Factory管道? - How to trigger Azure Data Factory pipeline using PowerShell (Azure Automation)? Azure DevOps 数据工厂数据集和管道 CI/CD 参数 - Azure DevOps Data Factory Dataset and pipeline CI/CD Parameters Azure 数据工厂管道 - Azure Data Factory pipeline Azure Data Factory V2-将管道发布到指定的文件夹 - Azure Data Factory V2 - publish pipeline to specified folder 在Azure DevOps Pipeline中的Azure Powershell步骤中引发“错误'***'未被识别为cmdlet的名称”错误 - “The term '***' is not recognized as the name of a cmdlet” error thrown in Azure Powershell step in Azure DevOps Pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM