I am trying to implement a time trigger function, which connects to Azure DB and get the contents from table. After this I'm looking out for the possibilities to write this data to a Azure Data lake file using BCP. Below is my function and Json Script
#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 Exception while executing function: Functions.OcDataTimerTriggerCSharp. mscorlib: Exception has been thrown by the target of an invocation. System: The system cannot find the file specified.