c# - Failing azure webjob -
my azure webjob keeps failing consistently exit code -2146232576. know exit code relates to?
i'm trying run on schedule, , source code can 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 initializing [06/15/2015 10:51:53 > 1e531f: sys info] run script 'trakimdb250.scraper.exe' script host - 'windowsscripthost' [06/15/2015 10:51:53 > 1e531f: sys info] status changed running [06/15/2015 10:51:53 > 1e531f: sys info] status changed failed [06/15/2015 10:51:53 > 1e531f: sys err ] job failed due 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 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 }; } } } }
my problem was flying close sun trying run .net 4.6.
downgraded solution 4.5.2 , worked :)
note: solution bound become irrelevant once 4.6 officially supported.
Comments
Post a Comment