繁体   English   中英

Azure WebJob未写入输出

[英]Azure WebJob not writing to output

我有一个Azure WebJob,它在本地调试时正在写入输出,但是当我在Azure中运行它时却没有。 “输出” blob容器完全为空,并且scm.azurewebsites.net站点中的“输出”窗口显示为灰色且为空白。 我是否需要进行任何设置才能将输出发送到那里?

这是它们的外观截图:

Webjob无输出

这是我在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);           
}

在您的代码中,您正在使用Console.WriteLine()编写日志。 要在WebJobs仪表板中显示输出,请使用TextWriter ,如下所示:

public static void InsertSQLData([BlobTrigger("blobcontainer/{name}")] Stream input,
                                 string name, TextWriter log)
{
    // ...
    log.WriteLine("some message");
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM