gpt4 book ai didi

c# - Azure Web作业失败(错误代码-2146232576)

转载 作者:太空狗 更新时间:2023-10-29 22:26:04 24 4
gpt4 key购买 nike

我的 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

相关代码:

程序.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"));
}
}
}

函数.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
};
}
}
}
}

最佳答案

我的问题是我在尝试运行 .NET 4.6 时飞得离太阳太近。

将解决方案降级到 4.5.2 并且完美运行:)

注意:一旦 4.6 正式支持,此解决方案必然变得无关紧要。

截至 2018 年 8 月 3 日,此兼容性问题仍然是一个问题。 .NET 4.7.2 会产生相同的错误,但降级到 4.7.1 可以正常工作。

关于c# - Azure Web作业失败(错误代码-2146232576),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30843469/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com