如何在 Azure 数据工厂管道中集成 WebJob
How to integrate a WebJob within an Azure Data Factory Pipeline
我正在尝试将 WebJob 集成到 ADF 管道中。
Webjob 是一个非常简单的控制台应用程序:
namespace WebJob4
{
class ReturnTest
{
static double CalculateArea(int r)
{
double area = r * r * Math.PI;
return area;
}
static void Main()
{
int radius = 5;
double result = CalculateArea(radius);
Console.WriteLine("The area is {0:0.00}", result);
}
}
}
我们如何通过 ADF 管道调用此 Web 作业并将响应代码(成功时为 HTTP 200)存储在 Azure Blob 存储中?
2018 年 12 月更新:
如果您正在考虑使用 azure 函数执行此操作,azure 数据工厂现在为您提供了一个 azure 函数步骤!基本原理与您必须使用 HTTP 触发器公开 azure 函数的原理相同。然而,这提供了更好的安全性,因为您可以使用 ACL
指定数据工厂实例对 azure 函数的访问权限
原答案
- 根据发表的评论,我相信您不想使用自定义活动路线。
- 您可以尝试为此使用复制任务,即使这可能不是预期目的。
- 有一个
httpConnector
可用于从 Web 源复制数据。
https://docs.microsoft.com/en-us/azure/data-factory/v1/data-factory-http-connector
- 复制任务触发了一个 http 端点,
- 您可以指定从基本到
OAuth2.
- 下面我使用端点来触发 azure 函数过程,输出保存在 datalake 文件夹中用于日志记录(显然你可以使用其他东西,就像在你的情况下它是 blob 存储。)
基本链接服务
{
"name": "linkedservice-httpEndpoint",
"properties": {
"type": "Http",
"typeProperties": {
"url": "https://azurefunction.api.com/",
"authenticationType": "Anonymous"
}
}
}
基本输入数据集
{
"name": "Http-Request",
"properties": {
"type": "Http",
"linkedServiceName": "linkedservice-httpEndpoint",
"availability": {
"frequency": "Minute",
"interval": 30
},
"typeProperties": {
"relativeUrl": "/api/status",
"requestMethod": "Get",
"format": {
"type": "TextFormat",
"columnDelimiter": ","
}
},
"structure": [
{
"name": "Status",
"type": "String"
}
],
"published": false,
"external": true,
"policy": {}
}
}
输出
{
"name": "Http-Response",
"properties": {
"structure": [
...
],
"published": false,
"type": "AzureDataLakeStore",
"linkedServiceName": "linkedservice-dataLake",
"typeProperties": {
...
},
"availability": {
...
},
"external": false,
"policy": {}
}
}
Activity
{
"type": "Copy",
"name": "Trigger Azure Function or WebJob with Http Trigger",
"scheduler": {
"frequency": "Day",
"interval": 1
},
"typeProperties": {
"source": {
"type": "HttpSource",
"recursive": false
},
"sink": {
"type": "AzureDataLakeStoreSink",
"copyBehavior": "MergeFiles",
"writeBatchSize": 0,
"writeBatchTimeout": "00:00:00"
}
},
"inputs": [
{
"name": "Http-Request"
}
],
"outputs": [
{
"name": "Http-Response"
}
],
"policy": {
...
}
}
我正在尝试将 WebJob 集成到 ADF 管道中。 Webjob 是一个非常简单的控制台应用程序:
namespace WebJob4
{
class ReturnTest
{
static double CalculateArea(int r)
{
double area = r * r * Math.PI;
return area;
}
static void Main()
{
int radius = 5;
double result = CalculateArea(radius);
Console.WriteLine("The area is {0:0.00}", result);
}
}
}
我们如何通过 ADF 管道调用此 Web 作业并将响应代码(成功时为 HTTP 200)存储在 Azure Blob 存储中?
2018 年 12 月更新:
如果您正在考虑使用 azure 函数执行此操作,azure 数据工厂现在为您提供了一个 azure 函数步骤!基本原理与您必须使用 HTTP 触发器公开 azure 函数的原理相同。然而,这提供了更好的安全性,因为您可以使用 ACL
指定数据工厂实例对 azure 函数的访问权限原答案
- 根据发表的评论,我相信您不想使用自定义活动路线。
- 您可以尝试为此使用复制任务,即使这可能不是预期目的。
- 有一个
httpConnector
可用于从 Web 源复制数据。
https://docs.microsoft.com/en-us/azure/data-factory/v1/data-factory-http-connector
- 复制任务触发了一个 http 端点,
- 您可以指定从基本到 OAuth2.
- 下面我使用端点来触发 azure 函数过程,输出保存在 datalake 文件夹中用于日志记录(显然你可以使用其他东西,就像在你的情况下它是 blob 存储。)
基本链接服务
{
"name": "linkedservice-httpEndpoint",
"properties": {
"type": "Http",
"typeProperties": {
"url": "https://azurefunction.api.com/",
"authenticationType": "Anonymous"
}
}
}
基本输入数据集
{
"name": "Http-Request",
"properties": {
"type": "Http",
"linkedServiceName": "linkedservice-httpEndpoint",
"availability": {
"frequency": "Minute",
"interval": 30
},
"typeProperties": {
"relativeUrl": "/api/status",
"requestMethod": "Get",
"format": {
"type": "TextFormat",
"columnDelimiter": ","
}
},
"structure": [
{
"name": "Status",
"type": "String"
}
],
"published": false,
"external": true,
"policy": {}
}
}
输出
{
"name": "Http-Response",
"properties": {
"structure": [
...
],
"published": false,
"type": "AzureDataLakeStore",
"linkedServiceName": "linkedservice-dataLake",
"typeProperties": {
...
},
"availability": {
...
},
"external": false,
"policy": {}
}
}
Activity
{
"type": "Copy",
"name": "Trigger Azure Function or WebJob with Http Trigger",
"scheduler": {
"frequency": "Day",
"interval": 1
},
"typeProperties": {
"source": {
"type": "HttpSource",
"recursive": false
},
"sink": {
"type": "AzureDataLakeStoreSink",
"copyBehavior": "MergeFiles",
"writeBatchSize": 0,
"writeBatchTimeout": "00:00:00"
}
},
"inputs": [
{
"name": "Http-Request"
}
],
"outputs": [
{
"name": "Http-Response"
}
],
"policy": {
...
}
}