Failure azure webjob

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

I am 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 magazines:

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

      

+3


source to share


1 answer


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

Stopped the solution to 4.5.2 and it worked great :)



Note. This decision will inevitably become irrelevant once version 4.6 has been officially approved.

+8


source







All Articles