You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过GitHub Actions向Azure App Service部署多容器应用时遭遇ERR_INVALID_CHAR错误的求助

通过GitHub Actions向Azure App Service部署多容器应用时遭遇ERR_INVALID_CHAR错误的求助

嗨,我刚好之前踩过这个坑!问题出在你对azure/webapps-deploy@v2的images参数用法理解有误——这个参数只支持单容器部署,多容器场景不能直接用多行列表放镜像地址,不然Action没办法正确生成Azure App Service需要的linuxfxversion配置头,才会抛出这个非法字符的错误。

Azure App Service的多容器部署依赖Docker Compose配置来管理容器的服务定义、网络、启动规则等,所以正确的做法是用Compose相关的参数来部署,给你两个简单的解决办法:

方法一:用项目里的Docker Compose文件部署

  1. 先在项目根目录创建一个docker-compose.yml,把你的多容器配置写进去:
version: '3.8'
services:
  app_main:
    image: example.azurecr.io/app_main:0.0.1-amd64
  helppage:
    image: example.azurecr.io/helppage:0.0.0v1-amd64
  1. 然后修改你的GitHub Action步骤,删掉images参数,换成docker-compose-path指定你的Compose文件路径:
steps:
  - name: Deploy to Azure Web App
    id: deploy-to-webapp
    uses: azure/webapps-deploy@v2
    with:
      app-name: 'newapp'
      slot-name: 'production'
      publish-profile: ${{ secrets.AzureAppService_PublishProfile_7c28e46039c5460897fa180b852b807d }}
      docker-compose-path: './docker-compose.yml'

方法二:在Workflow里内联Compose配置(不用单独存文件)

如果不想在项目里加额外的Compose文件,也可以直接在Action里用docker-compose-content参数写配置:

steps:
  - name: Deploy to Azure Web App
    id: deploy-to-webapp
    uses: azure/webapps-deploy@v2
    with:
      app-name: 'newapp'
      slot-name: 'production'
      publish-profile: ${{ secrets.AzureAppService_PublishProfile_7c28e46039c5460897fa180b852b807d }}
      docker-compose-content: |
        version: '3.8'
        services:
          app_main:
            image: example.azurecr.io/app_main:0.0.1-amd64
          helppage:
            image: example.azurecr.io/helppage:0.0.0v1-amd64

这样部署的时候,Action会根据Compose配置生成正确的多容器环境参数,就不会再出现那个错误了!

备注:内容来源于stack exchange,提问作者ABK

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 12:37:40