簡體   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