c# - 如何使用提交到 git 存储库的 Azure 数据工厂 json 文件通过代码创建组件
问题描述
我不知道这是否应该是这样使用的,但我是这样看待这个过程的:
- 在连接到我的 git 存储库的 Azure 数据工厂工作室中创建/编辑组件。
- 提交对 repo 的更改以创建 json 定义文件
- 在 C# 程序中使用这些文件在实时环境中“创建或更新”我的组件
以下是我提交更改时生成的文件的一些示例:
Test3Json.json:
{
"name": "Test3Json",
"properties": {
"linkedServiceName": {
"referenceName": "AzureBlobStorage1",
"type": "LinkedServiceReference"
},
"parameters": {
"FullPath": {
"type": "string"
}
},
"annotations": [],
"type": "Json",
"typeProperties": {
"location": {
"type": "AzureBlobStorageLocation",
"fileName": {
"value": "@dataset().FullPath",
"type": "Expression"
}
}
},
"schema": {}
}
}
Test2JsonOutput.json:
{
"name": "Test2JsonOutput",
"properties": {
"linkedServiceName": {
"referenceName": "AzureBlobStorage1",
"type": "LinkedServiceReference"
},
"parameters": {
"OutputPath": {
"type": "string"
}
},
"annotations": [],
"type": "Json",
"typeProperties": {
"location": {
"type": "AzureBlobStorageLocation",
"folderPath": {
"value": "@dataset().OutputPath",
"type": "Expression"
},
"container": "reporting"
}
},
"schema": {}
},
"type": "Microsoft.DataFactory/factories/datasets"
}
Test3Dataflow.json:
{
"name": "Test3Dataflow",
"properties": {
"type": "MappingDataFlow",
"typeProperties": {
"sources": [
{
"dataset": {
"referenceName": "Test3Json",
"type": "DatasetReference"
},
"name": "source1"
}
],
"sinks": [
{
"dataset": {
"referenceName": "Test2JsonOutput",
"type": "DatasetReference"
},
"name": "sink1"
}
],
"transformations": [],
"script": "source(allowSchemaDrift: true,\n\tvalidateSchema: false,\n\tignoreNoFilesFound: false,\n\tdocumentForm: 'documentPerLine') ~> source1\nsource1 sink(allowSchemaDrift: true,\n\tvalidateSchema: false,\n\tskipDuplicateMapInputs: true,\n\tskipDuplicateMapOutputs: true) ~> sink1"
}
}
}
然后我根据这篇文章,说明可以通过代码创建或更新组件。
为了在 C# 程序中创建数据集并基于 json 文件,我使用了类似的东西。它正在创建它,但它似乎无法使用,因为在创建后在 Data Factory Studio 中查看它时缺少属性:
public class AzureDataFactoryResourceWrapper<T>
{
public string Name { get; set; }
public T Properties { get; set; }
public string Type { get; set; }
}
private async Task CreateDataSet(string jsonDefinition)
{
var resource = JsonSerializer.Deserialize<AzureDataFactoryResourceWrapper<AzureBlobDataset>>(jsonDefinition, optionsCaseInsensitive);
var dataset = new DatasetResource(resource.Properties);
await client.Datasets.CreateOrUpdateAsync(resourceGroup, dataFactoryName, resource.Name, dataset);
}
但是,当我尝试对 DataFlow 执行相同操作时,似乎 json 文件中定义的属性与DataFlowResource
C# 类的定义不匹配,在将 json 反序列化为对象后,我到处都得到 NULL。
private async Task CreateDataFlow(string jsonDefinition)
{
var resource = JsonSerializer.Deserialize<AzureDataFactoryResourceWrapper<DataFlowResource>>(jsonDefinition, optionsCaseInsensitive);
var dataFlow = resource.Properties;
await client.DataFlows.CreateOrUpdateAsync(resourceGroup, dataFactoryName, resource.Name, dataFlow);
}
json 文件是否应该可用于通过代码创建组件?
这是正确的方法吗?
如果无法使用 json 文件来创建组件,那么将 git 与数据工厂一起使用的目的是什么?
解决方案
推荐阅读
- node.js - FS readFile 在获取请求中不返回任何内容
- odoo - Odoo 控制器接收 blob
- java - 迭代 ArrayList 并添加到具有特定格式的另一个 arrayList
- azure - 将 Azure Key Vault 与 ASP.NET 4.0 集成
- php - 为 foreach() 和 index.php 提供的无效参数不显示任何内容
- c - 使用c struct实现链表
- c++ - Int 未在方法中更新
- css - 如何在 MUI 中设置 body 元素的样式
- ansible - 从剧本编辑 Ansible 保险库文件
- azure-active-directory - B2C issuerAssignedId 的联合 AAD 使用什么?