skip to Main Content

I am trying to deploy a webapp to azure through github actions, however the site/wwwroot folder is completely empty upon completion

  • Nothing fails within the pipeline
  • The artifact published has the correct files
  • If I manually FTP the files to wwwroot then it works as expected

Any ideas would be appreciated

Snippet of .yaml below

name: Build and deploy 
on:
  push:
    branches:
    - main    
  workflow_dispatch:
env:
  AZURE_WEBAPP_NAME: Name
  AZURE_WEBAPP_PACKAGE_PATH: Namepublish
  CONFIGURATION: Release
  DOTNET_CORE_VERSION: 6.0.x
  WORKING_DIRECTORY: Name
jobs:
  build:
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v3
    - name: Setup .NET SDK
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
    - name: Restore
      run: dotnet restore "${{ env.WORKING_DIRECTORY }}"
    - name: Build
      run: dotnet build "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-restore
    - name: Test
      run: dotnet test "${{ env.WORKING_DIRECTORY }}" --no-build
    - name: Publish
      run: dotnet publish "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-build --output "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}"
    - name: Publish Artifacts
      uses: actions/upload-artifact@v3
      with:
        name: webapp
        path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
  deploy:
    runs-on: windows-latest
    needs: build
    steps:
    - name: Download artifact from build job
      uses: actions/download-artifact@v3
      with:
        name: webapp
        path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
    - name: Deploy to Azure WebApp
      uses: azure/webapps-deploy@v3
      with:
        app-name: ${{ env.AZURE_WEBAPP_NAME }}
        publish-profile: ${{ secrets.Name_BBF6 }}
        package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

Also snippet of action log:

Package deployment using OneDeploy initiated.
{
  id: '11111111111111',
  status: 4,
  status_text: '',
  author_email: 'N/A',
  author: 'N/A',
  deployer: 'OneDeploy',
  message: 'OneDeploy',
  progress: '',
  received_time: '2023-11-21T11:17:41.9110402Z',
  start_time: '2023-11-21T11:17:42.1610338Z',
  end_time: '2023-11-21T11:17:44.5828528Z',
  last_success_end_time: '2023-11-21T11:17:44.5828528Z',
  complete: true,
  active: true,
  is_temp: false,
  is_readonly: true,
  url: 'https://name.scm.azurewebsites.net/api/deployments/latest',
  log_url: 'https://name.scm.azurewebsites.net/api/deployments/latest/log',
  site_name: 'Name',
  provisioningState: 'Succeeded'
}
Deploy logs can be viewed at https://name.scm.azurewebsites.net/api/deployments/1111111111/log
Successfully deployed web package to App Service.

2

Answers


  1. Chosen as BEST ANSWER

    The response from @Harshitha ended up taking me down the right path, changing to v2 with package . led me to this issue Problem with deploying Web API C# to Azure App Service when i use github actions

    Fixing this, in turn fixed my issue strangely, I think App Insights added this config setting automatically as I never manually set it.

    Changing WEBSITE_NODE_DEFAULT_VERSION = ~18 instead of 6.9.1 was the fix needed.

    Thanks for your help.


  2. The issue seems to be with your yaml file Upload and Deploy path.

    In Azure portal, whenever you enable GitHub Actions settings while create Azure Web App Service

    enter image description here

    or

    Configuring GitHub from Deployment Center,

    enter image description here

    yaml file will be generated automatically.You can check the preview option as well.

    My yaml file:

    
    name: Build and deploy ASP.Net Core app to Azure Web App - Core622Nov
    
    on:
      push:
        branches:
          - main
      workflow_dispatch:
    
    jobs:
      build:
        runs-on: windows-latest
    
        steps:
          - uses: actions/checkout@v4
    
          - name: Set up .NET Core
            uses: actions/setup-dotnet@v1
            with:
              dotnet-version: '6.0.x'
              include-prerelease: true
    
          - name: Build with dotnet
            run: dotnet build --configuration Release
    
          - name: dotnet publish
            run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
    
          - name: Upload artifact for deployment job
            uses: actions/upload-artifact@v3
            with:
              name: .net-app
              path: ${{env.DOTNET_ROOT}}/myapp
    
      deploy:
        runs-on: windows-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: .net-app
    
          - name: Deploy to Azure Web App
            id: deploy-to-webapp
            uses: azure/webapps-deploy@v2
            with:
              app-name: 'Core622Nov'
              slot-name: 'Production'
              publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_6C3057D1BD9741F5B2093B5402A8853F }}
              package: .
    
    • In Upload artifact the path has to be ${{env.DOTNET_ROOT}}/myapp
    • In deploy,the package has to be set to .

    Build Action:
    enter image description here

    My wwwroot directory
    enter image description here

    Output:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search