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

使用GitHub Actions部署容器到Azure Container Apps时遇runtime-platform错误

解决Azure Container Apps部署时的runtime-platform错误

问题背景

我有一个Spring Boot API,通过GitHub Actions的CI/CD流程部署到Azure Container Apps。向main分支提交代码后,流程执行到镜像部署阶段时,持续触发runtime-platform错误。即使已在YAML配置文件中指定runtime-platform: linux/amd64,问题仍未解决。

错误日志

Unable to find image 'mcr.microsoft.com/oryx/cli:builder-debian-buster-20230208.1' locally
builder-debian-buster-20230208.1: Pulling from oryx/cli
d42a0fb443d7: Pulling fs layer
f390d41539fb: Pulling fs layer
103b21370b9f: Pulling fs layer
fddd5b6145de: Pulling fs layer
16dfd13d3a05: Pulling fs layer
27df7571ea34: Pulling fs layer
99ad81e721c7: Pulling fs layer
4136820462f5: Pulling fs layer
6c84a682b950: Pulling fs layer
6e38c43918bc: Pulling fs layer
9beff6fb6da7: Pulling fs layer
61093d47cb77: Pulling fs layer
205ffbb9f89d: Pulling fs layer
fddd5b6145de: Waiting
16dfd13d3a05: Waiting
6e38c43918bc: Waiting
27df7571ea34: Waiting
99ad81e721c7: Waiting
9beff6fb6da7: Waiting
61093d47cb77: Waiting
205ffbb9f89d: Waiting
4136820462f5: Waiting
f390d41539fb: Download complete
103b21370b9f: Verifying Checksum
103b21370b9f: Download complete
16dfd13d3a05: Verifying Checksum
16dfd13d3a05: Download complete
d42a0fb443d7: Verifying Checksum
d42a0fb443d7: Download complete
27df7571ea34: Verifying Checksum
27df7571ea34: Download complete
99ad81e721c7: Verifying Checksum
99ad81e721c7: Download complete
fddd5b6145de: Verifying Checksum
fddd5b6145de: Download complete
6e38c43918bc: Verifying Checksum
6e38c43918bc: Download complete
6c84a682b950: Verifying Checksum
6c84a682b950: Download complete
9beff6fb6da7: Verifying Checksum
9beff6fb6da7: Download complete
4136820462f5: Verifying Checksum
4136820462f5: Download complete
d42a0fb443d7: Pull complete
205ffbb9f89d: Verifying Checksum
205ffbb9f89d: Download complete
f390d41539fb: Pull complete
61093d47cb77: Verifying Checksum
61093d47cb77: Download complete
103b21370b9f: Pull complete
fddd5b6145de: Pull complete
16dfd13d3a05: Pull complete
27df7571ea34: Pull complete
99ad81e721c7: Pull complete
4136820462f5: Pull complete
6c84a682b950: Pull complete
6e38c43918bc: Pull complete
9beff6fb6da7: Pull complete
61093d47cb77: Pull complete
205ffbb9f89d: Pull complete
Digest: sha256:2d5eaa1e75ef73b5bf461a573d8fdf40cb7bc1596be2f0b044f5eb0231a8e94c
Status: Downloaded newer image for mcr.microsoft.com/oryx/cli:builder-debian-buster-20230208.1
Error: Either the value provided to the --runtime-platform argument is empty, or the platform discovered by Oryx does not have any available or supported runtime images. Please view the following document for more information on runtimes supported by Oryx: https://aka.ms/oryx-runtime-images

原GitHub Actions配置

name: Trigger auto deployment for search-service-production

# When this action will be executed
on:
  # Automatically trigger it when detected changes in repo
  push:
    branches: 
      [ main ]
    paths:
    - '**'
    - '.github/workflows/search-service-production-AutoDeployTrigger-b9ef6edb-c114-41e7-be4e-b7087d14ea7f.yml'

  # Allow manually trigger 
  workflow_dispatch:
      
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout to the branch
        uses: actions/checkout@v2

      - name: Azure Login
        uses: azure/login@v1
        with:
          creds: ${{ secrets.SEARCHSERVICEPRODUCTION_AZURE_CREDENTIALS }}

      - name: Set up JDK 17
        uses: actions/setup-java@v2
        with:
          java-version: '17'
          distribution: 'adopt'
          cache: 'gradle'

      - name: Grant execute permission for gradlew
        run: chmod +x gradlew

      - name: Build and Push ACR Image
        env:
          ACR_REGISTRY: mytest.azurecr.io  # Replace with your ACR login server
          ACR_REPOSITORY: tfs-search-service  # Replace with the desired ACR repository
          ACR_IMAGE_TAG: ${{ github.sha }}
        run: |
          ./gradlew jib -Djib.to.auth.username=${{ secrets.SEARCHSERVICEPRODUCTION_REGISTRY_USERNAME }}\
            -Djib.to.auth.password=${{ secrets.SEARCHSERVICEPRODUCTION_REGISTRY_PASSWORD }} \
            -Djib.to.image=mytest.azurecr.io/tfs-search-service:${{ github.sha }}

      - name: Build and Deploy to Azure Container Apps
        uses: azure/container-apps-deploy-action@v1
        with:
          appSourcePath: ${{ github.workspace }} 
          registryUrl: mytest.azurecr.io
          registryUsername: ${{ secrets.SEARCHSERVICEPRODUCTION_REGISTRY_USERNAME }}
          registryPassword: ${{ secrets.SEARCHSERVICEPRODUCTION_REGISTRY_PASSWORD }}
          containerAppName: search-service-production
          resourceGroup: mytest-production
          runtime-platform: linux/amd64
          imageToDeploy: mytest.azurecr.io/search-service-production:${{ github.sha }}

问题分析与解决方案

核心问题

  1. 重复构建冲突:azure/container-apps-deploy-action@v1 同时收到 appSourcePath 和 imageToDeploy 参数时,会优先尝试用Oryx重新构建镜像,而非直接部署已推送到ACR的镜像。Oryx自动检测runtime时与指定的linux/amd64平台产生冲突,触发错误。
  2. 镜像路径不一致:Jib推送的镜像路径是mytest.azurecr.io/tfs-search-service:${{ github.sha }},但部署阶段指定的imageToDeploy是mytest.azurecr.io/search-service-production:${{ github.sha }},两者不匹配,导致找不到正确镜像。

修复步骤

  1. 移除不必要的构建参数:删除appSourcePath: ${{ github.workspace }},让action直接使用已构建好的ACR镜像。
  2. 修正镜像路径:将imageToDeploy的值改为与Jib推送的路径一致,即mytest.azurecr.io/tfs-search-service:${{ github.sha }}。
  3. 保留runtime-platform指定:确保runtime-platform: linux/amd64参数正确传递,匹配镜像的构建平台。

修改后的部署步骤配置

- name: Build and Deploy to Azure Container Apps
  uses: azure/container-apps-deploy-action@v1
  with:
    registryUrl: mytest.azurecr.io
    registryUsername: ${{ secrets.SEARCHSERVICEPRODUCTION_REGISTRY_USERNAME }}
    registryPassword: ${{ secrets.SEARCHSERVICEPRODUCTION_REGISTRY_PASSWORD }}
    containerAppName: search-service-production
    resourceGroup: mytest-production
    runtime-platform: linux/amd64
    imageToDeploy: mytest.azurecr.io/tfs-search-service:${{ github.sha }}

验证方案

  1. 推送修改后的GitHub Actions配置到main分支,触发自动部署。
  2. 查看GitHub Actions日志,确认部署阶段不再拉取Oryx镜像,直接使用ACR中的镜像完成部署。
  3. 访问Azure Container Apps控制台,确认应用成功启动并运行。

内容的提问来源于stack exchange,提问作者MetaCoder

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 06:47:04