将使用python脚本的java web应用部署到Azure
我正在开发java web应用程序,我正在尝试使用一种简单的人工智能算法——NLP来解析文本。 我想从我的应用程序NLP.py中运行一个python脚本,它使用驻留在本地pc上的另一个文件(3 Gb大小)中的数据,我下载了python插件,并按如下方式运行脚本:将使用python脚本的java web应用部署到Azure,java,python,azure,spring-boot,azure-web-app-service,Java,Python,Azure,Spring Boot,Azure Web App Service,我正在开发java web应用程序,我正在尝试使用一种简单的人工智能算法——NLP来解析文本。 我想从我的应用程序NLP.py中运行一个python脚本,它使用驻留在本地pc上的另一个文件(3 Gb大小)中的数据,我下载了python插件,并按如下方式运行脚本: String pythonScriptPath = "MY-PATH\\NLP\\NLP.py"; String[] cmd = new String[3]; cmd[0] = "python"; // ch
String pythonScriptPath = "MY-PATH\\NLP\\NLP.py";
String[] cmd = new String[3];
cmd[0] = "python"; // check version of installed python: python -V
cmd[1] = pythonScriptPath;
cmd[2]="playing sport";
// create runtime to execute external command
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(cmd);
文件层次结构:
现在我想在Azure上运行所有这些东西,我没有找到任何相关教程,我将该应用部署为常规web应用,但我仍然不知道:
D:\home\site\wwwroot\ProcessFile
但是,azure web app文件系统存储受应用程序服务的限制。(你可以在门户上查看)因此,如果你的文件太大,你需要将它们存储到Azure存储中
2.写什么路径而不是MY-path
只需按照上面的绝对路径D:\home\site\wwwroot\ProcessFile\NLP.py
3.python脚本将如何在Azure上运行,我应该使用什么资源以及如何使用
据我所知,Azure Web App有自己的Python环境,但您无权更改它。由于您使用的是NLP
,它涉及依赖项包,因此我建议您安装Python扩展
有关步骤的详细信息,请按照我之前回答的案例进行操作
一,
二,
安装包后,需要更改代码中的路径参数
String python= "D:\home\python362x86\python.exe";
String pythonScriptPath = "D:\home\site\wwwroot\ProcessFile\NLP.py";
String[] cmd = new String[3];
cmd[0] = "python"; // check version of installed python: python -V
cmd[1] = pythonScriptPath;
cmd[2]="playing sport";
// create runtime to execute external command
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(cmd);
希望对你有帮助。如果有任何问题,请随时告诉我。如果我还有任何问题,我会告诉你。非常感谢您的详细回答!嗨,Jay Gong,正如您所解释的,我试图将脚本使用的文件上载到我的Azure应用程序项目中的新文件夹,但它没有上载,这可能是因为文件的大小,您能否解释如何将该文件添加到Azure存储帐户,以及以这种方式的路径是什么?非常感谢你!