سؤال

Today I started using the Azure Web Jobs running a node.js script which outputs a json file in the same directory. I'd like to consume that file using http now, however I can't figure out what the right uri is. I figured it must be similar to where the logs are (which btw. tell me that the job ran successfully), but I can't seem to find the json file. Shouldn't it be something like this? https://SiteName.scm.azurewebsites.net/JobName/output.json

EDIT: I just opened the site using Webmatrix, and though I can find the job files (under /App_Data/jobs/triggered/JobName), it seems like the json file wasn't saved though the log says so. Anyone knows if you can save files in a webjob like this?

fs.writeFile(outputFilename, JSON.stringify(output, null, 4), function(err) {
    if(err) {
        console.log(err);
    } else {
        console.log("JSON saved to " + outputFilename);
    }
});  

Btw. you have to edit the Web.config if you want to server static JSON with Azure: http://blogs.msdn.com/b/africaapps/archive/2013/06/07/how-to-serve-static-json-files-from-a-windows-azure-website.aspx

هل كانت مفيدة؟

المحلول

The reason the file is not next to the WebJob's binaries is that before the WebJob is invoked it is first copied to a temporary directory (%temp%\jobs\triggered\jobName\randomName) and is run from there, this way no file is locked and you can update the WebJob's binaries at any time.

The appropriate path to use when persisting a file with a WebJob is using the WEBROOT_PATH environment variable as it has the path to your wwwroot.

If you want this file to only be accessible privately (as wwwroot is publicly visible), you can go up one level, for example: %WEBROOT_PATH%/../output.json.

Another option is to use: d:\home, for context wwwroot is at: d:\home\site\wwwroot.

To access that file use the following url: https://SiteName.scm.azurewebsites.net/vfs/site/output.json and you'll need to provide your deployment credentials.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top