Home > Net >  GitHub Action error for Azure Webapp: Specify a project or solution file. The current working direct
GitHub Action error for Azure Webapp: Specify a project or solution file. The current working direct

Time:01-17

I am trying to deploy a small WebApp with GitHub Actions into an Azure WebApp deployment slot. The WebApp in Azure is called webappdeploydemo and the deployment slot development. The WebApp is based on .NET 6 LTS stack. For this I use an ubuntu runner and the following YAML-configuration:

name: 'Deploy to Azure App Service'

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

env:
  AZURE_WEBAPP_PACKAGE_PATH: '.'
  AZURE_WEBAPP_NAME: webappdeploydemo
jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    
    - name: Setup .NET
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: 6.0.x
      
    - name: Build
      run: dotnet build --configuration Release
    
    - name: Publish
      run: dotnet publish -c Release -o '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapplication'
      
    - name: Deploy
      uses: Azure/webapps-deploy@v2
      with:
        app-name: ${{ env.AZURE_WEBAPP_NAME }}
        slot-name: 'development'
        publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
        package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapplication'

When triggering the GitHub Action I have an error at the build step, which I am trying to understand and solve. In understood that it can't find a sln or .net project at that path. But why and how can I overcome this?

enter image description here

CodePudding user response:

I am able to create a development slot without any issues. Please follow the below steps.

Make sure your source files are deployed properly to GitHub. Check the folder structure before you continue the steps.

  • In Visual Studio, Create a .NET Core 6 Web App.
  • Push the code to GitHub Repository.
  • New files .gitattributes and .gitignore will be created in the GitHub Repo along with the Source Code.

enter image description here

  • Make sure your GitRepository has all the required solution and folder structure.

enter image description here

  • Create a new App Service.

enter image description here

  • Enable Continuous deployment for GitHub Actions.

enter image description here

  • Workflow folder will be created in the GitHub Repo.
    enter image description here

Output:
enter image description here

Creating Deployment Slots:

  • In Azure Portal => Navigate to your App Service => select Deployment slots Under Deployment .

  • As we have deployed the Application to Azure, we will find one Production slot.

enter image description here

  • Create one development slot. Provide the name and select the deployed App Service to clone all the deployed configurations and settings to development slot from Production slot.
    enter image description here

  • As it is a sample App, it takes few seconds to create the slot.

enter image description here

  • Check the newly created development slot under All Resources.

enter image description here

Initial Output of Development Slot:

enter image description here

  • Now we need to set the continuous deployment and integrate the GitHub Repo code.
  • In Visual Studio, create a new branch for Development.

enter image description here

  • Commit and push the changes of new branch.

enter image description here

  • In GitHub, click on View all branches, you will find a new branch.

enter image description here

  • Navigate to the Development slot. Now integrate the GitHub development branch for the development slot and click on Save.

enter image description here

Final Output for Development Slot:

enter image description here

  • Related