Azure / Github 部署不再起作用

问题描述 投票:0回答:1

过去,我会使用 Github 集成通过 Azure 部署 Spring boot 应用程序。因此,当将 Web 应用程序添加到 azure 时,我表明我要部署一个 Github 项目。这在过去非常有效。

现在,2024 年 3 月 21 日,我想做同样的事情。因此,我在 Azure 中创建了一个名为 backend 的 Web 应用程序,并通过指示我要部署 github 项目来使用 Azure 部署新的 Web 应用程序。我可以看到在我的项目的 github 中,创建了一个 .github/workflows 文件夹,其中包含工作流文件。在 github 的“操作”选项卡中,我可以看到工作流文件已启动一个操作,但是部署失败,因为我收到资源backend不存在的错误!这曾经有效。 Azure 中是否存在已知错误,导致通过 github 的部署不再起作用?

azure github deployment
1个回答
0
投票

查看在 GitHub 存储库的

.github/workflows
目录中创建的工作流程文件。确保它 检查 GitHub 存储库的
.github/workflows
目录中的工作流程文件。确保它指定正确的 Azure Web App 名称(“后端”)并包含适当的配置。查找工作流程文件中的任何错误或错误配置。

我开发了一个简单的 Hello world Java Spring Boot 应用程序,并使用 GitHub 成功将其部署到 Azure 应用服务。

本地输出:

enter image description here

出于部署目的,我运行了以下命令:

mvn clean install

我在Azure中创建了一个Web应用程序,如下所示。

enter image description here

填写必要的详细信息后,单击“审核+创建”选项。

enter image description here

创建 Web 应用程序后,转到部署中心,选择 GitHub 作为源,然后填写必要的详细信息,如下所示。

enter image description here

enter image description here

enter image description here

以下是我的 GitHub 工作流程配置。

.github/workflow 配置:

name: Build and deploy JAR app to Azure Web App - <AzureWebAppName>

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Set up Java version
        uses: actions/setup-java@v1
        with:
          java-version: '17'

      - name: Build with Maven
        run: mvn clean install

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v3
        with:
          name: java-app
          path: '${{ github.workspace }}/target/*.jar'

  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
      
    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v3
        with:
          name: java-app
      
      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v2
        with:
          app-name: '<AzureWebAppName>'
          slot-name: 'Production'
          package: '*.jar'
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_<key> }}

我成功将Spring Boot应用程序部署到Azure App Service,如下所示。

enter image description here

Azure 应用服务输出

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.