如何通过 git 将多个 WebJobs 部署到应用服务

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

我对 Azure e Git 使用还很陌生,在通过 Git 将 2 WebJob 部署到 Azure 应用服务时遇到一些问题。 当我部署其中一个时,它会取代另一个。 我是否缺少一些配置?

当通过 Visual Studio 部署工作正常时,我可以将这 2 个 WebJobs 放在一起,但我真的需要知道如何通过 Git 来完成它。

.yml


on:
  workflow_dispatch:  

env:
  WEBJOB1_NAME: CUSTOMER
  WEBJOB2_NAME: PRODUCT  
  DOTNET_VERSION: '3.1.x'

jobs:   
            
  customer-dev-release:
    name: Release customer to DEV
    runs-on: ubuntu-latest
    environment: CUSTOMER-DEV
    steps:
      # Checkout the repo
      - uses: actions/checkout@v2

      # Setup .NET Core SDK
      - name: Setup .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: ${{ env.DOTNET_VERSION }}
        
      - name: Build with dotnet        
        run: |
          dotnet build --configuration Release
           
      - name: dotnet test
        run: |
          dotnet test --no-build --no-restore --verbosity normal --configuration Release             

      - name: dotnet publish
        run: |
          dotnet publish -c Release -o './App_Data/Jobs/Continuous/${{ env.WEBJOB1_NAME }}'
     
        
      - name: Deploy to Azure App Service
        uses: azure/webapps-deploy@v2
        with: 
          app-name: ACCOUNT-DEV
          publish-profile: ${{ secrets.PUBLISH_PROFILE_DEV }}
          package: '.'


  product-dev-release:
    name: Release product to DEV
    runs-on: ubuntu-latest
    environment: PRODUCT-DEV
    steps:
      # Checkout the repo
      - uses: actions/checkout@v2

      # Setup .NET Core SDK
      - name: Setup .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: ${{ env.DOTNET_VERSION }}
        
      - name: Build with dotnet        
        run: |
          dotnet build --configuration Release
           
      - name: dotnet test
        run: |
          dotnet test --no-build --no-restore --verbosity normal --configuration Release 

      - name: dotnet publish
        run: |
          dotnet publish -c Release -o './App_Data/Jobs/Continuous/${{ env.WEBJOB2_NAME }}'     
        
      - name: Deploy to Azure App Service
        uses: azure/webapps-deploy@v2
        with: 
          app-name: ACCOUNT-DEV
          publish-profile: ${{ secrets.PUBLISH_PROFILE_DEV }}
          package: '.'

请问有什么建议吗?

azure-webjobs azure-appservice
2个回答
0
投票
  1. 将您的 Web 作业与 Web 应用程序关联,在 Visual Studio 中右键单击您的 Web 应用程序项目并选择 添加 > 现有项目作为 Azure WebJob

  2. 将 webjobs 包含在 Web 应用程序包中之后。

  3. 将 Web 应用程序部署到 azure 应用程序服务。

  4. 它将在发布到 azure 期间生成 webjobs 包。您需要在 Azure 应用服务部署任务中指定 Web 应用程序包。请参阅此处了解步骤

将您的项目添加到 GIT 存储库并使用 azure 配置它以进行持续部署

请参阅通过 git 部署多个 Web 作业了解更多信息


0
投票

使用操作 azure/webapps-deploy@v3 而不是 v2。就我而言,我使用以下操作解决了我的问题

  • 名称:部署到 Azure Web App

      uses: azure/webapps-deploy@v3
      with:
        app-name: ${{ env.AZURE_WEBAPP_NAME }}
        publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }}
        package: .
        clean: false
    
© www.soinside.com 2019 - 2024. All rights reserved.