Failing azure webjob (error code -2146232576)

4.1k views Asked by At

My Azure WebJob keeps failing consistently with the exit code -2146232576. Does anyone know what the exit code relates to?

I'm trying to run it on a schedule, and my source code can be found here:

https://github.com/luke-barnett/trakt-imdb250/tree/master/TrakIMDB250.Scraper

Relevant logs:

[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

Relevant code:

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

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
                };
            }
        }
    }
}
1

There are 1 answers

1
Technicolour On BEST ANSWER

My problem was that I was flying too close to the sun trying to run .NET 4.6.

Downgraded the solution to 4.5.2 and it worked perfectly :)

Note: this solution is bound to become irrelevant once 4.6 is officially supported.

As of 8/3/2018, this compatibility issue continues to be a problem. .NET 4.7.2 produces this same error, but downgrading to 4.7.1 works.