skip to Main Content

Problem definition

I am developing ASP.NET MVC 7 application. I want to enable CI/CD, however this is my first use of Azure services. I tried to create App Service through Azure portal and enable Github actions (standard .yaml workflow that is automatically set by Azure). Everything succeeded.

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy ASP.Net Core app to Azure Web App - YouInvestMe

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '7.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@v2
        with:
          name: .net-app
          path: ${{env.DOTNET_ROOT}}/myapp

  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@v2
        with:
          name: .net-app

      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v2
        with:
          app-name: 'YouInvestMe'
          slot-name: 'Production'
          publish-profile: ${{ secrets.PUBLISH_PROFILE }}
          package: .

However, when to access the website via ***.azurewebsites.net, it says the webapp is running and waiting for my content.

I have tried to check over all files that are in /home/site/wwwroot/ and mostly they are .dll files. Accessing the terminal with Web SSH, I even tried running the main .dll with dotnet command, and it worked but on localhost:5000, so I couldn’t see.

Q: How can I configure/deploy my project so that app get live and CI enabled with database schema update on every push?

N.B. The project uses MySQL database, and it is set up and running on Azure. Connection strings are fine.

Here’s what I get:

Problem

This is latest deployment via GitHub Actions
Lates logs

If there is not enough info, I will edit the question.

2

Answers


  1. I have deployed the ASP.NET MVC7 App to Azure App service using GitHub Actions.

    Initially even I got the same Content page.

    enter image description here

    If we got the content page, it means that our App is deployed successfully, but there is no default page to serve the app.

    • In the deployed Azure App Service => Configuratuion =>Default Documents, add a new document Index.cshtml.

    enter image description here

    • All the deployed files/folders will be under wwwroot directory.

    I have tried to check over all files that are in /home/site/wwwroot/ and mostly they are .dll files.

    • Once the Application is deployed, all the files are compiled into dll files. You cannot find any of the forms/files (Controllers/.cshtml) directly.

    My deployed Project folder Structure
    enter image description here

    • If you still get any issue, update the web.config file in the Kudu Console wwwroot directory(stdoutLogEnabled false to true).
     <aspNetCore processPath="dotnet" arguments=".SimpleWebAppMVC.dll" stdoutLogEnabled="true" stdoutLogFile=".logsstdout" hostingModel="inprocess" />
    
    • Now try to access the Url,a log file will be created with the clear error description in wwwroot => logs folder.

    enter image description here

    How can I configure/deploy my project so that app get live and CI enabled with database schema update on every push?

    • In Azure Portal, while creating Azure App Service, enable the GitHub Actions settings while creating the App Service itself.

    • This option enables to continuously deploy the app whenever new change/commit is done in the repository.

    enter image description here

    Login or Signup to reply.
  2. I had a similar problem when using the Azure-generated GitHub Action workflow.

    I came to the conclusion, that script generated doesn’t behave correctly when your solution has many projects.

    In my scenario, once I created a Test project inside the solution, the deployment had that result.

    Why? Because the dotnet publish step doesn’t specify the project.

    So this:

    - name: dotnet publish
      run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
    

    Should be this:

    - name: dotnet publish
      run: dotnet publish MyApplication/MyApplication.csproj -c Release -o ${{env.DOTNET_ROOT}}/myapp
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search