简体   繁体   English

使用node.js的Azure Web Jobs输出文件的URI

[英]URI of Azure Web Jobs output file with node.js

Today I started using the Azure Web Jobs running a node.js script which outputs a json file in the same directory. 今天,我开始使用运行node.js脚本的Azure Web作业,该脚本在同一目录中输出json文件。 I'd like to consume that file using http now, however I can't figure out what the right uri is. 我现在想使用http来使用该文件,但是我不知道正确的uri是什么。 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. 我认为它必须类似于日志所在的位置(顺便说一句,告诉我作业已成功运行),但是我似乎找不到json文件。 Shouldn't it be something like this? 不应该是这样吗? https://SiteName.scm.azurewebsites.net/JobName/output.json 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. 编辑:我刚刚使用Webmatrix打开了站点,尽管我可以找到作业文件(在/ App_Data / jobs / triggered / JobName下),但似乎日志中并未保存json文件。 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 如果要使用Azure服务器静态JSON,则必须编辑Web.config: http : //blogs.msdn.com/b/africaapps/archive/2013/06/07/how-to-serve-static-json-文件从-一个窗口,蔚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. 该文件不在WebJob二进制文件旁边的原因是,在调用WebJob之前,该文件首先被复制到一个临时目录( %temp%\\jobs\\triggered\\jobName\\randomName )并从那里运行,这样就没有文件了锁定,您可以随时更新WebJob的二进制文件。

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. 当使用WebJob持久保存文件时,使用的适当路径是使用WEBROOT_PATH环境变量,因为它具有您的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 . 如果您只想私下访问此文件(因为wwwroot是公共可见的),则可以上一层,例如: %WEBROOT_PATH%/../output.json

Another option is to use: d:\\home , for context wwwroot is at: d:\\home\\site\\wwwroot . 另一个选择是使用: d:\\home ,对于上下文wwwroot,位于: 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. 要访问该文件,请使用以下URL: https : //SiteName.scm.azurewebsites.net/vfs/site/output.json ,您需要提供部署凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM