简体   繁体   English

如何检索azure数据工厂管道的json表示?

[英]How do I retrieve the json representation of an azure data factory pipeline?

I want to track pipeline changes in source control, and I'm looking for a way to programmatically retrieve the json representation from the ADF. 我想跟踪源代码管理中的管道更改,我正在寻找一种以编程方式从ADF中检索json表示的方法。

The .Net routines return the objects, but sadly ToString() does not return json (wouldn't THAT be convenient?), so right now I'm looking at copying the json down by hand (shoot me now!), or possibly trying to recreate the json from the .Net objects (shoot me later!). .Net例程返回对象,但遗憾的是ToString()不返回json(这不方便吗?),所以现在我正在手工复制json(现在开枪!),或者可能试图从.Net对象重新创建json(稍后再拍!)。

Please tell me I'm being dense and there is an obvious way to do this. 请告诉我,我是密集的,有一个明显的方法来做到这一点。

You can serialize the object using Newtonsoft Json. 您可以使用Newtonsoft Json序列化对象。 See ( https://azure.microsoft.com/en-us/documentation/articles/data-factory-create-data-factories-programmatically/ ) for how to connect via the ADF SDK 有关如何通过ADF SDK进行连接,请参阅( https://azure.microsoft.com/en-us/documentation/articles/data-factory-create-data-factories-programmatically/

var aadTokenCredentials = new TokenCloudCredentials(ConfigurationManager.AppSettings["SubscriptionId"], GetAuthorizationHeader());

var resourceManagerUri = new Uri(ConfigurationManager.AppSettings["ResourceManagerEndpoint"]);
var manager = new DataFactoryManagementClient(aadTokenCredentials, resourceManagerUri);
var pipeline = manager.Pipelines.Get(resourceGroupName, dataFactoryName, pipelineName);
var pipelineAsJson = JsonConvert.SerializeObject(pipeline.Pipeline, Formatting.Indented);

I was expecting something more complex but looking at the sdk source GitHub it is not doing anything special. 我期待更复杂的东西,但是看看sdk源GitHub它没有做任何特别的事情。

Our team has a deployment tool that takes git changes and deploy them appropriately. 我们的团队有一个部署工具,可以进行git更改并适当地部署它们。 Everything is done asynchronously and being controlled and versioned through git. 一切都是异步完成的,并通过git进行控制和版本控制。 In a nutshell our deployment has the following flow: 简而言之,我们的部署具有以下流程:

  • Any completed git merge request triggers a VSO build. 任何完成的git合并请求都会触发VSO构建。 This is simply building the whole solution via MsBuild. 这只是通过MsBuild构建整个解决方案。

  • Every successful build is applied a Git tag for tracking of Last Known Good. 每个成功的构建都应用Git标记来跟踪Last Known Good。

  • Next (if build succeeded) our .net ADFPublisher starts by taking only the changed data factory files and asynchronously publishing them based on their git operation (modified, add, delete, etc.). 接下来(如果构建成功)我们的.net ADFPublisher首先只获取已更改的数据工厂文件,并根据他们的git操作(修改,添加,删除等)异步发布它们。

  • For some failures cases our ADFPublisher will perform a retry. 对于某些故障情况,我们的ADFPublisher将执行重试。

    This whole process (Build + publish) takes ~ 65 seconds and has already saved us from having several bugs. 整个过程(构建+发布)大约需要65秒,并且已经使我们免于出现多个错误。 It also allows us to move definitions from one environment to another very easily. 它还允许我们非常轻松地将定义从一个环境移动到另一个环境。

Let me know if you think this is something that you will be interested in and I will setup a way to share it with you 如果您认为这是您感兴趣的内容,请告诉我,我将设置一种方式与您分享

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM