1
我想实现一个时间触发器函数,它连接到Azure DB并从表中获取内容。在此之后,我正在寻找使用BCP将此数据写入Azure数据湖文件的可能性。下面是我的功能和JSON脚本是否可以从Azure数据库表读取数据并将其写入Azure Data Lake文件并使用Azure功能?
#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:异常已被调用的目标抛出。系统:系统找不到指定的文件。
这是可能的。请详细说明您面临的具体问题以及您迄今为止所做的解决方案。否则,这个问题太广泛了。 – Mikhail