Reputation: 7259
I have an Azure WebJob that was writing to the output when I debugged it locally, but doesn't when I run it in Azure. The Output blob container is completely empty and the output window in the scm.azurewebsites.net
site is greyed out and blank. Do I need to set anything up to get my output to be sent there?
Here is a screenshot of what they both look like:
Here is the code I'm running on the Webjob:
public static void InsertSQLData([BlobTrigger("blobcontainer/{name}")] Stream input, string name)
{
var sw = new Stopwatch();
sw.Start();
RetryAbleBCP rtbcp = new RetryAbleBCP(input,
"dbo.FullText",
ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString,
SqlBulkCopyOptions.Default,
',',
500,
null);
try
{
rtbcp.BulkInsertCSV();
}
catch (OutOfMemoryException eoom)
{
Console.WriteLine(eoom.Message);
}
catch (IOException eio)
{
Console.WriteLine(eio.Message);
}
catch (InvalidOperationException eiop)
{
Console.WriteLine(string.Format("Row {0}: {1}", rtbcp.NumRowsRead, eiop.Message));
}
catch (SqlException se)
{
Console.WriteLine(se.Message);
}
catch (Exception e)
{
Console.WriteLine(string.Format("General Application Exception: {0}", e.Message));
}
sw.Stop();
Console.Out.WriteLine("Finished Batch Insert. Elapsed: {0}ms", sw.ElapsedMilliseconds);
}
Upvotes: 2
Views: 2319
Reputation: 4154
In your code you are writing logs using Console.WriteLine()
. To have the output show up in the WebJobs dashboard, use TextWriter
, like so:
public static void InsertSQLData([BlobTrigger("blobcontainer/{name}")] Stream input,
string name, TextWriter log)
{
// ...
log.WriteLine("some message");
}
Upvotes: 4