问题描述

在Azure App Service for Windows 中部署web项目时候,需要在wwwroot下设置web.config,对于不同语言的项目,web.config文件中的httpPlatform模块内容则有大大的不同。以下内容则为Java,Python, NodeJS语言列出web.config模板:

.NET Core OutOfProcess 

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\myweb.dll" stdoutLogEnabled="true" stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="outofprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 50fa4d0f-11ac-4592-ac22-10be4278dd9b-->

.NET Core inProcess 

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\myweb.dll" stdoutLogEnabled="true" stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 50fa4d0f-11ac-4592-ac22-10be4278dd9b-->

Java

方式一: 启动Jar包的Web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>
    <httpPlatform processPath="%JAVA_HOME%\bin\java.exe" stdoutLogEnabled ="true" stdoutLogFile="%home%\LogFiles\stdout"
        arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar &quot;%HOME%\site\wwwroot\my-web-project.jar&quot; "  >   
   </httpPlatform>
  </system.webServer>
</configuration>
  • stdoutLogEnabled: 为true则会在stdoutLogFile文件夹中记录java启动的日志
  • arguments: 配置jar包的启动参数,如端口号,jar包路径,也可以配置utf-8编码方式,避免乱码问题。

方式二: 启动War包的Web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httppPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers> <httpPlatform processPath="%AZURE_TOMCAT8_HOME%\bin\startup.bat">
</httpPlatform>
</system.webServer>
</configuration>

Python

一:配置 HttpPlatform 处理程序为Python.exe

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="D:\home\Python361x64\python.exe"
arguments="D:\home\site\wwwroot\runserver.py --port %HTTP_PLATFORM_PORT%"
stdoutLogEnabled="true"
stdoutLogFile="D:\home\LogFiles\python.log"
startupTimeLimit="60"
processesPerApplication="16">
<environmentVariables>
<environmentVariable name="SERVER_PORT" value="%HTTP_PLATFORM_PORT%" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>

二:配置 FastCGI 处理程序

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="PYTHONPATH" value="D:\home\site\wwwroot"/>
<!-- The handler here is specific to Bottle; other frameworks vary. -->
<add key="WSGI_HANDLER" value="app.wsgi_app()"/>
<add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/>
</appSettings>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="FastCgiModule"
scriptProcessor="D:\home\Python361x64\python.exe|D:\home\Python361x64\wfastcgi.py"
resourceType="Unspecified" requireAccess="Script"/>
</handlers>
</system.webServer>
</configuration>
  • PYTHONPATH 的值可以自由扩展,但必须包括你的应用的根目录。
  • WSGI_HANDLER 必须指向可从你的应用导入的 WSGI 应用。
  • WSGI_LOG 为可选,但建议在调试应用时使用。

NodeJS

<?xml version="1.0" encoding="utf-8"?>
<!--
This configuration file is required if iisnode is used to run node processes behind
IIS or IIS Express. For more information, visit: https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
--> <configuration>
<system.webServer>
<!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
<webSocket enabled="false" />
<handlers>
<!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
<add name="iisnode" path="index.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<!-- Do not interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^index.js\/debug[\/]?" />
</rule> <!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule> <!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="index.js"/>
</rule>
</rules>
</rewrite> <!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security> <!-- Make sure error responses are left untouched -->
<httpErrors existingResponse="PassThrough" /> <!--
You can control how Node is hosted within IIS using the following options:
* watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
* node_env: will be propagated to node as NODE_ENV environment variable
* debuggingEnabled - controls whether the built-in debugger is enabled See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
-->
<!--<iisnode watchedFiles="web.config;*.js"/>-->
</system.webServer>
</configuration>

参考资料

Java sample for Azure App Service: https://github.com/Azure-Samples/app-service-web-java-get-started

将 web.config 设置为指向 Python 解释器: https://docs.microsoft.com/zh-cn/visualstudio/python/managing-python-on-azure-app-service?view=vs-2019

Node.js Hello World: https://github.com/Azure-Samples/nodejs-docs-hello-world

【Azure 应用服务】在Azure App Service for Windows 中部署Java/NodeJS/Python项目时,web.config的配置模板内容的更多相关文章

  1. 【Azure 应用服务】在 App Service for Windows 中自定义 PHP 版本的方法

    问题描述 在App Service for Windows的环境中,当前只提供了PHP 7.4 版本的选择情况下,如何实现自定义PHP Runtime的版本呢? 如 PHP Version 8.1.9 ...

  2. 【Azure 应用服务】Azure Mobile App (NodeJS) 的服务端部署在App Service for Windows中出现404 Not Found -- The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

    问题描述 使用NodeJS的后端应用,开发一个Mobile App的服务端,手机端通过REST API来访问获取后端数据.在本地编译好后,通过npm start启动项目,访问效果如下: 但是,当把项目 ...

  3. 【Azure 应用服务】一个 App Service 同时部署运行两个及多个 Java 应用程序(Jar包)

    问题描述 如何在一个AppService下同时部署运行多个Java 应用程序呢? 问题解答 因为App Service的默认根目录为 wwwroot.如果需要运行多个Java 应用程序,需要在 www ...

  4. 【Azure 应用服务】App Service for Linux 中实现 WebSocket 功能 (Python SocketIO)

    问题描述 使用 python websockets 模块作为Socket的服务端,发布到App Service for Linux环境后,发现Docker Container无法启动.错误消息为: 2 ...

  5. 【Azure 应用服务】Azure App Service For Linux 上实现 Python Flask Web Socket 项目 Http/Https

    问题描述 在上篇博文"[Azure 应用服务]App Service for Linux 中实现 WebSocket 功能 (Python SocketIO)"中,实现了通过 HT ...

  6. 【Azure 应用服务】NodeJS Express + MSAL 应用实现AAD集成登录并部署在App Service Linux环境中的实现步骤

    问题描述 实现部署NodeJS Express应用在App Service Linux环境中,并且使用Microsoft Authentication  Library(MSAL)来实现登录Azure ...

  7. windows一键部署java项目

    windows一键部署java项目 因为公司需求,要在windows的环境上做一键部署启动java项目,同时还要支持从安装界面动态修改配置文件的IP地址.就像安装软件一样将jdk,tomcat,mys ...

  8. 在windows中:双击运行Python程序、后台运行Python程序

    在windows中:双击运行Python程序.后台运行Python程序 安装Python解释器的windows环境,如果双击运行*.py的文件,会闪退.怎样避免闪退呢? 我们用python的日志输出程 ...

  9. 在Windows中实现Java调用DLL(转载)

    本文提供调用本地 C 代码的 Java 代码示例,包括传递和返回某些常用的数据类型.本地方法包含在特定于平台的可执行文件中.就本文中的示例而言,本地方法包含在 Windows 32 位动态链接库 (D ...

  10. 【Azure 应用服务】App Service For Windows 环境中部署Python站点后,如何继续访问静态资源文件呢(Serving Static Files)?

    问题描述 当创建一个App Service 后,运行时环境和版本选择Windows 和 Python 3.6. 登录Kudu 站点查看,默认的文件有 web.config, hostingstart- ...

随机推荐

  1. 使用linux上面powershell安装vm powercli 连接vcenter 通过计划任务自动创建部分虚拟机的快照以及自动清理过期快照的办法

    经过一晚上的折腾, 终于验证出来一个非常简单的方法. 也比较好理解和使用. 这里简单记录一下: 使用linux上面powershell安装vm powercli 连接vcenter 通过计划任务自动创 ...

  2. unzip 解压缩存在Bug-- 这个方法不行啊

    linux中解压大于4G的zip压缩包(已解决) tar -zxvf 压缩包名.zip

  3. 2023年了,做SEO还有必要吗?

    作者:京东科技 吴磊 搜索引擎工作原理 在搜索引擎网站的后台会有一个非常庞大的数据库,里面存储了海量的关键词,而每个关键词又对应着很多网址,这些网址是被称之为"搜索引擎蜘蛛"或&q ...

  4. 【记录一个问题】golang 中的 ecdsa(椭圆曲线加密) 算法很慢,因为用到了系统调用

    代码中使用了椭圆曲线算法来签名,实际运行中发现不够快: func BenchmarkECDSA(b *testing.B) { privateKeyInst, err := parseSignatur ...

  5. 小白学k8s(1)二进制部署k8s

    二进制部署k8s 前言 准备工作 关闭防火墙 关闭 swap 分区 关闭 SELinux 更新系统时间 秘钥免密码 设置主机名称 服务器角色 安装etcd 创建证书 生成证书 部署Etcd 在Node ...

  6. 【链表】链表OJ-力扣2074. 反转偶数长度组的节点【超详细的算法解释】

    说在前面 今天博主给大家带来的是力扣上的一道链表OJ,完成这道题后,博主感觉这题覆盖了很多链表的解题思想,另外,这道题对指针的控制也是比较高的.在这里博主将这道好题分享给大家! 另外,对于链表等数据结 ...

  7. 基于OpenCV-Python的图像位置校正和版面分析

    前言 使用opencv对图像进行操作,要求:(1)定位银行票据的四条边,然后旋正.(2)根据版面分析,分割出小写金额区域. 图像校正 首先是对图像的校正 读取图片 对图片二值化 进行边缘检测 对边缘的 ...

  8. P4396 [AHOI2013] 作业 题解

    题目链接:作业 其实可以类似"HH的项链"转化为偏序问题再 cdq 分治.不过这题感觉莫队然后值域分块很好写啊,基本不用动脑. 考虑查询的两个信息: \(a \le x\le b\ ...

  9. Linux--如何查看磁盘的IO(top、iostat)

    问题背景: 在性能测试时,虽然测试出了结果,但是我们并不知道瓶颈是源端,还是目标端.例如我做上传和下载性能验证,从Linux服务器上向OSS集群上传和下载文件,虽然测试出了速率,但是并不知道上传是否存 ...

  10. C语言程序设计之字符串处理

    C语言程序设计-字符串处理 第一题:回文数判断 问题描述] 回文是正读和倒读都一样的句子.读入一个最大长度不超过50个字符的句子,判断其是否是回文. [输入形式] 输入一个最大长度不超过50个字符的句 ...