【问题标题】:Is it possible to read data from Azure Data base table and write it to Azure Data Lake file with Azure functions?是否可以使用 Azure 函数从 Azure 数据库表中读取数据并将其写入 Azure Data Lake 文件?
【发布时间】:2017-06-19 11:07:45
【问题描述】:

我正在尝试实现一个时间触发功能,它连接到 Azure DB 并从表中获取内容。在此之后,我正在寻找使用 BCP 将此数据写入 Azure 数据湖文件的可能性。下面是我的函数和 Json 脚本

#r "System.Configuration"
#r "System.Data"
#r "System.IO"
using System.Configuration;
using System.Data.SqlClient;
using System.Threading.Tasks;
using System;
using System.IO;
using System.Net;
public static void Run(TimerInfo myTimer, TraceWriter log)
{
    var str = ConfigurationManager.ConnectionStrings["sqldb_connection"].ConnectionString;
    log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
    using (SqlConnection conn = new SqlConnection(str))
    {
    conn.Open();
    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.StartInfo.FileName = "bcp";
    proc.StartInfo.Arguments = "\"select * from Person \""+ "queryout 'DatalakeFilepath' -S test-server.database.windows.net -U username -P password  -d database -N";
    proc.Start();
    }
}


//Json:
{
  "bindings": [
    {
      "name": "myTimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 */5 * * * *"
    }
  ],
  "disabled": false
}

2017-06-19T11:29:31.957 执行函数时出现异常:Functions.OcDataTimerTriggerCSharp。 mscorlib:调用的目标已引发异常。系统:系统找不到指定的文件。

【问题讨论】:

  • 有可能。请详细说明您面临的确切问题以及到目前为止您为解决该问题所做的工作。否则,问题就太宽泛了。

标签: azure azure-functions azure-data-lake


【解决方案1】:

(此处为 Azure 数据湖团队)

从 Azure 函数写入 Azure Data Lake Store (ADLS) 是可能的 - 但不是您在上面的代码中执行的方式。

您不能像本地驱动器或文件共享一样写入 ADLS 文件系统。因此,使用 ADLS 帐户中的目标路径调用 BCP 将不起作用。

有几个选项供您选择。 Azure 函数可以:

  • 运行 ADF 管道
  • 启动 U-SQL 作业以读取 Azure SQL 并写入 ADLS。
  • 手动逐行读取 SQL DB 并将行写入 ADLS

【讨论】:

    猜你喜欢
    • 2018-10-04
    • 1970-01-01
    • 1970-01-01
    • 2019-10-28
    • 1970-01-01
    • 2019-06-08
    • 2021-11-10
    • 2019-09-23
    • 1970-01-01
    相关资源
    最近更新 更多