Tec*_*our 5 c# azure azure-webjobs
我的Azure WebJob始终以退出代码-2146232576失败.有谁知道退出代码与什么有关?
我正按计划运行它,我的源代码可以在这里找到:
https://github.com/luke-barnett/trakt-imdb250/tree/master/TrakIMDB250.Scraper
相关日志:
[06/15/2015 10:51:51 > 1e531f: SYS INFO] Status changed to Initializing
[06/15/2015 10:51:53 > 1e531f: SYS INFO] Run script
'TrakIMDB250.Scraper.exe' with script host - 'WindowsScriptHost'
[06/15/2015 10:51:53 > 1e531f: SYS INFO] Status changed to Running
[06/15/2015 10:51:53 > 1e531f: SYS INFO] Status changed to Failed
[06/15/2015 10:51:53 > 1e531f: SYS ERR ] Job failed due to exit code -2146232576
Run Code Online (Sandbox Code Playgroud)
相关代码:
Program.cs中
using Microsoft.Azure.WebJobs;
namespace TrakIMDB250.Scraper
{
class Program
{
static void Main(string[] args)
{
var config = new JobHostConfiguration();
var host = new JobHost(config);
host.Call(typeof(Functions).GetMethod("ScrapeIMDB250"));
}
}
}
Run Code Online (Sandbox Code Playgroud)
functions.cs
using HtmlAgilityPack;
using Microsoft.Azure.WebJobs;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace TrakIMDB250.Scraper
{
public class Functions
{
[NoAutomaticTrigger]
public async static Task ScrapeIMDB250(TextWriter log)
{
await log.WriteLineAsync("[{0}] Starting scrapping of IMDB Top 250");
var html = new HtmlWeb().Load("http://www.imdb.com/chart/top");
var chartTable = html.DocumentNode.SelectSingleNode("//table[@class='chart']");
var movies = GetMovies(chartTable).OrderBy(movie => movie.Rank);
await log.WriteLineAsync("[{0}] Got movies");
var storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["Storage"].ConnectionString);
var blobClient = storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference("imdb-top250");
await container.CreateIfNotExistsAsync();
await container.SetPermissionsAsync(new BlobContainerPermissions
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
var jsonblob = container.GetBlockBlobReference("top250.json");
await jsonblob.UploadTextAsync(JsonConvert.SerializeObject(movies, Formatting.Indented));
await log.WriteLineAsync("[{0}] Written to blob storage");
}
static IEnumerable<Movie> GetMovies(HtmlNode chartTable)
{
foreach (var row in chartTable.SelectNodes(".//tr").Skip(1))
{
var title = row.SelectSingleNode("td[@class='titleColumn']");
var rankSpan = title.SelectSingleNode("span[@name='ir']");
var seenWidget = row.SelectSingleNode("td/span[@name='ur']/div");
var name = title.SelectSingleNode("a").InnerText;
var rank = int.Parse(new string(rankSpan.InnerText.Take(rankSpan.InnerText.Count() - 1).ToArray()));
var rating = decimal.Parse(rankSpan.GetAttributeValue("data-value", "0"));
var imdbid = seenWidget.GetAttributeValue("data-titleid", string.Empty);
var releaseDate = DateTime.Parse(title.SelectSingleNode("span[@name='rd']").GetAttributeValue("data-value", string.Empty));
yield return new Movie
{
Name = name,
Rank = rank,
Rating = rating,
IMDBId = imdbid,
ReleaseDate = releaseDate
};
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
Tec*_*our 10
我的问题是我飞得太靠近太阳试图运行.NET 4.6.
将解决方案降级到4.5.2,它完美地运行:)
注意:一旦4.6得到官方支持,这个解决方案必将变得无关紧要.
截至8/3/2018,此兼容性问题仍然是一个问题..NET 4.7.2产生同样的错误,但降级到4.7.1有效.
| 归档时间: |
|
| 查看次数: |
2898 次 |
| 最近记录: |