【Azure Web App】Github Action部署Jar包到App Service报400错误

简介: 通过GitHub Action部署Azure App Service时遇400错误,根源在于Jar包无法部署至Stack为Tomcat的应用。需将App Service运行栈改为Java SE,并可通过az CLI或curl复现验证。最终确认Kudu源码中对部署类型有严格校验。

问题描述

通过github aciton部署azure app service服务的时候,遇见400报错。

报错信息非常简单:

Starting deployment for web app...

Package deployment using OneDeploy initiated.

Error: Failed to deploy web package to App Service.

Error: Deployment Failed, Error: Failed to deploy web package using OneDeploy to App Service.

Bad Request (CODE: 400)

这个问题应该如何调查呢?

 

问题解答

在Github Aciton中,使用 Azure WebApp(azure/webapps-deploy@v3)来部署App Service的应用, 这次部署的是一个jar包。

Github Action 脚本:

- name: Azure WebApp

uses: azure/webapps-deploy@v3

with:

app-name: '<app service name>'

package: ${{ github.workspace }}/target/*.jar

查看Azure文档,介绍部署java应用时,使用az cli命令,github action和maven 插件都是使用的Kudu OneDeploy接口( https://<your web app>.scm.chinacloudsites.cn/api/publish?type=jar )

(文档链接:https://docs.azure.cn/zh-cn/app-service/configure-language-java-deploy-run?tabs=linux&pivots=java-tomcat#deploying-your-app)

 

根据以上信息,就尝试使用az webapp deploy命令直接部署jar包应用,发现多了一句错误提示信息:

> az webapp deploy --resource-group <your resource group name> --name <your app service name> --src-path myjava.jar --type jar

Initiating deployment

Deploying from local path: myjava.jar

An error occurred during deployment. Status Code: 400,

Details: "Artifact type = 'Jar' cannot be deployed to stack = 'TOMCAT'. Site should be configured to run with stack = JAVA",

Please visit https://XXXXXXXXX.scm.chinacloudsites.cn/api/deployments/latest to get more information about your deployment

这句错误消息非常关键(Artifact type = 'Jar' cannot be deployed to stack = 'TOMCAT'. Site should be configured to run with stack = JAVA")。

在查看App Service的配置信息后,Stack果然设置为Tomcat。

因为这里只有两种选项( Tomcat 和Java SE )。于是,修改为Java SE后,再次部署jar包。

成功。

 

当问题解决后,想进一步验证是否是one deploy接口对jar包的强制限制。

恰好kudu也是开源项目,所以,进入github kudu 仓库 (源码:https://github.com/projectkudu/kudu/tree/master ),使用错误消息关键字整库搜索“cannot be deployed to stack”,最终,定位到 PushDeploymentController.cs 中,有如下的验证条件:

  • 当部署的文件为Jar时,需要判断目标App Service的Stack只能是JavaSE。如果不是,返回400的状态码

 

附录一:使用 curl 命令直接调用接口也可以复现问题,效果和az webapp deploy命令相同

curl -X POST \
     -u user:password \
     -T "/Users/Downloads/xxxxx-0.0.1-SNAPSHOT.jar" \
     "https://xxxxx.scm.chinacloudsites.cn/api/publish?type=jar" \
     -v
* Host xxxxx.scm.chinacloudsites.cn:443 was resolved.
* IPv6: (none)
* IPv4: 159.27.20.0
*   Trying 159.27.20.0:443...
* Connected to xxxxx.scm.chinacloudsites.cn (159.27.20.0) port 443
* ALPN: curl offers h2,http/1.1
* (304) (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (IN), TLS handshake, Server hello (2):
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384 / [blank] / UNDEF
* ALPN: server accepted http/1.1
* Server certificate:
*  subject: C=CN; ST=Shanghai; O=Shanghai Blue Cloud Technology Co., Ltd.; CN=*.chinacloudsites.cn
*  start date: Dec 19 00:00:00 2025 GMT
*  expire date: Jun 17 23:59:59 2026 GMT
*  subjectAltName: host "xxxxx.scm.chinacloudsites.cn" matched cert's "*.scm.chinacloudsites.cn"
*  issuer: C=US; O=DigiCert Inc; CN=DigiCert Basic RSA CN CA G2
*  SSL certificate verify ok.
* using HTTP/1.x
* Server auth using Basic with user 'deploypoc'
> POST /api/publish?type=jar HTTP/1.1
> Host: xxxxx.scm.chinacloudsites.cn
> Authorization: Basic xxxxxxxxxxxxxxxx
> User-Agent: curl/8.7.1
> Accept: */*
> Content-Length: 25578166
> Expect: 100-continue
> 
* Done waiting for 100-continue
< HTTP/1.1 400 Bad Request
< Content-Type: text/plain; charset=utf-8
< Date: Wed, 31 Dec 2025 03:42:36 GMT
< Server: Kestrel
< Set-Cookie: ARRAffinity=xxxx;Path=/;HttpOnly;Secure;Domain=xxxxx.scm.chinacloudsites.cn
< Set-Cookie: ARRAffinitySameSite=xxxxx;Path=/;HttpOnly;SameSite=None;Secure;Domain=xxxxx.scm.chinacloudsites.cn
< Transfer-Encoding: chunked
< 
* HTTP error before end of send, stop sending
* abort upload after having sent 589824 bytes
* Closing connection
Artifact type = 'Jar' cannot be deployed to stack = 'TOMCAT'. Site should be configured to run with stack = JAVA%

 

参考资料

App Service部署Java应用:https://docs.azure.cn/zh-cn/app-service/configure-language-java-deploy-run?tabs=linux&pivots=java-tomcat#deploying-your-app

Kudu One Deploy Source Code : https://github.com/projectkudu/kudu/blob/master/Kudu.Services/Deployment/PushDeploymentController.cs#L304

 



当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

相关文章
|
5月前
|
Web App开发 安全 前端开发
2026年建设网站的十个步骤
2026 年优质网站建设十大关键步骤涵盖需求分析、架构规划等全生命周期环节,以 PageAdmin 低代码平台为支撑,兼顾设计、开发、测试、部署与运维,可高效构建功能完善、体验优良的专业网站,契合多元需求与长期发展目标。
731 2
|
5月前
|
Linux 虚拟化 iOS开发
UTM 4.7.5 发布 - 在 macOS 上优雅的使用 QEMU 虚拟化 Windows、Linux 和 macOS
UTM 4.7.5 发布 - 在 macOS 上优雅的使用 QEMU 虚拟化 Windows、Linux 和 macOS
989 0
UTM 4.7.5 发布 - 在 macOS 上优雅的使用 QEMU 虚拟化 Windows、Linux 和 macOS
|
5月前
|
弹性计算 NoSQL 数据挖掘
2026年阿里云服务器核心配置优惠价格解析:2 核 4G、4 核 8G 选型指南
阿里云服务器通过 “轻量应用服务器” 与 “云服务器 ECS” 两大品类,覆盖从个人开发到企业级业务的需求,其中 1 核 2G、2 核 4G、4 核 8G 为最具代表性的配置,价格与性能随实例类型、计费方式差异显著。本文基于官方定价与实测数据,梳理核心配置的价格体系、性能特点及适配场景,为用户提供客观选型参考。
|
5月前
|
人工智能 安全 算法
游戏盾技术解析:如何为多行业构建免疫DDoS攻击的防护体系
游戏盾是新一代网络安全防护方案,针对游戏、直播、金融等行业面临的DDoS、CC等攻击,采用全球分布式节点、智能调度、加密隧道与AI行为分析技术,实现99.9%以上防护成功率,保障低延迟与高可用。支持SDK集成,提供定制化防护,助力企业应对数字时代安全挑战。(238字)
181 0
|
5月前
|
缓存 监控 开发者
Python装饰器:让代码优雅加倍
Python装饰器:让代码优雅加倍
338 135
|
5月前
|
人工智能 运维 自然语言处理
2025 必藏 RPA 清单:从国际巨头到国产新锐,小白也能轻松上手的智能工具
RPA(机器人流程自动化)正成为企业数字化转型的核心工具,广泛应用于金融、电商、政务等领域。它如同“数字员工”,可自动完成重复性电脑操作,提升效率3-5倍且错误率低于0.1%。2025年全球市场规模达145亿美元,中国市场增速领先。本文盘点三款主流RPA工具:国际标杆UiPath、微软生态利器Power Automate,以及融合AI的国产新锐实在Agent,助力个人与企业高效选型,释放人力价值。
1540 9
|
5月前
|
安全 机器人 API
WhatsApp 账号共存模式解析:如何实现手机 App 与 API 同时在线?
随着业务扩展,很多企业希望在保留 WhatsApp 手机端人工服务的同时,接入 API 实现自动化营销。本文将详解 Meta 最新的“账号共存”模式,并介绍如何通过 阿里云 Chat App 的原生集成能力,轻松实现手机 App 与 API 后台的同步协作,兼顾服务温度与运营效率。
609 1
|
5月前
|
API 数据格式 Windows
通过 KlineCharts 获取和展示印度股票数据
本文介绍如何通过KlineCharts对接印度股票数据,涵盖获取股票PID、调用K线接口、数据格式转换及图表渲染全流程。支持日线、小时线等周期,并可扩展实时更新功能,助力快速实现K线图展示。
|
5月前
|
消息中间件 存储 人工智能
风控不是算账,是“盯人”——聊聊 CEP 在风控与监控里的那些真本事
风控不是算账,是“盯人”——聊聊 CEP 在风控与监控里的那些真本事
455 1
|
5月前
|
文字识别 开发者 Windows
Windows 上值得推荐的软件(第一弹)
本文推荐两款提升Windows使用效率的神器:Listary,实现文件快速搜索与路径跳转;uTools,集快捷启动、剪贴板智能识别与丰富插件于一体,助力高效办公。
357 0
Windows 上值得推荐的软件(第一弹)