0

I created a basic ASP.NET Razor pages project called learningapptest. Then I created a github repository called learningapptest.

I then pushed up my basic ASP.NET project to github. In the Azure Portal, I went to my basic web app.

I selected deployment center, I picked GitHub as the source, I made sure I was signed in.

I selected Erikw343 as the organization, and selected learningapptest as the repository; I selected main as the branch.

I took the rest as the defaults and clicked save.

Then, I got this error message:

Run nuget restore
The folder 'D:\a\learningapptest\learningapptest' does not contain an msbuild solution or packages.config file to restore.
Error: Process completed with exit code 1

Although, my project does have a packages.config file!

This is my main_learningapperik.yml file:

    # 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 app to Azure Web App - learningapperik

    on:
      push:
        branches:
          - main
      workflow_dispatch:

    jobs:
      build:
        runs-on: windows-latest
        permissions:
          contents: read #This is required for actions/checkout
    
        steps:
          - uses: actions/checkout@v4

          - name: Setup MSBuild path
            uses: microsoft/[email protected]

          - name: Setup NuGet
            uses: NuGet/[email protected]

          - name: Restore NuGet packages
            run: nuget restore

          - name: Publish to folder
            run: msbuild /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="\published\"

          - name: Upload artifact for deployment job
            uses: actions/upload-artifact@v4
            with:
              name: ASP-app
              path: '/published/**'

              deploy:
                runs-on: windows-latest
                needs: build
        permissions:
           id-token: write #This is required for requesting the JWT
           contents: read #This is required for actions/checkout

        steps:
          - name: Download artifact from build job
            uses: actions/download-artifact@v4
            with:
              name: ASP-app
  
          - name: Login to Azure
            uses: azure/login@v2
            with:
              client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_F6348B2E31F94008973B341661415A87 }}
              tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_6F3985F493BC43D09123DC142720057F }}
              subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_8BE450D5FE7840ECB96C8E7C3E95A8A4 }}

          - name: Deploy to Azure Web App
            id: deploy-to-webapp
            uses: azure/webapps-deploy@v3
            with:
             app-name: 'learningapperik'
             slot-name: 'Production'
              package: .
      

This is a link to my public GitHub learningapptest project: https://github.com/erikw343/learningapptest

look here for the failed actions: https://github.com/erikw343/learningapptest/actions

I changed my YAML file to this, and it fixed the build errors, but now I have deploy errors:

    # 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 app to Azure Web App - learningapperik

    on:
      push:
        branches:
          - main
      workflow_dispatch:

    jobs:
      build:
        runs-on: windows-latest
        permissions:
          contents: read #This is required for actions/checkout

        steps:
          - uses: actions/checkout@v4

          - name: Setup MSBuild path
            uses: microsoft/[email protected]

          - name: Setup NuGet
            uses: NuGet/[email protected]

          - name: Restore NuGet packages
            run: nuget restore learningapptest/learningapptest.sln

          - name: Publish to folder
            run: msbuild learningapptest/learningapptest.sln /nologo /verbosity:m /t:Build /p:_PackageTempDir="\published\"

          - name: Upload artifact for deployment job
            uses: actions/upload-artifact@v4
            with:
              name: ASP-app
              path: '/published/**'

      deploy:
        runs-on: windows-latest
        needs: build
        permissions:
          id-token: write #This is required for requesting the JWT
          contents: read #This is required for actions/checkout

        steps:
          - name: Download artifact from build job
            uses: actions/download-artifact@v4
            with:
              name: ASP-app
  
          - name: Login to Azure
            uses: azure/login@v2
            with:
              client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_F6348B2E31F94008973B341661415A87 }}
              tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_6F3985F493BC43D09123DC142720057F }}
              subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_8BE450D5FE7840ECB96C8E7C3E95A8A4 }}

          - name: Deploy to Azure Web App
            id: deploy-to-webapp
            uses: azure/webapps-deploy@v3
            with:
              app-name: 'learningapperik'
              slot-name: 'Production

My new issue now is this:

    Run actions/download-artifact@v4
      with:
        name: ASP-app
        merge-multiple: false
        repository: erikw343/learningapptest
        run-id: 19995715081
    Downloading single artifact
    Error: Unable to download artifact(s): Artifact not found for name: ASP-app
            Please ensure that your artifact is not expired and the artifact was uploaded using a compatible version of toolkit/upload-artifact.
            For more information, visit the GitHub Artifacts FAQ: https://github.com/actions/toolkit/blob/main/packages/artifact/docs/faq.md
3
  • I noticed that this error also occurs after pushing up my local repo to github.com. So, it has nothing to do with Azure! Commented Dec 6 at 19:52
  • The main_learningapperik.yml file is still on GitHub.com there controlling it from Azure. Commented Dec 6 at 20:07
  • I got it to work completely. I will post an answer later. Commented Dec 7 at 0:58

1 Answer 1

0

So, I had to fix the main_learningapperik.yml file, here is the new working file:

# 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 app to Azure Web App - learningapperik

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: windows-latest
    permissions:
      contents: read #This is required for actions/checkout

    steps:
      - uses: actions/checkout@v4

      - name: Setup MSBuild path
        uses: microsoft/[email protected]

      - name: Setup NuGet
        uses: NuGet/[email protected]

      - name: Restore NuGet packages
        run: nuget restore learningapptest/learningapptest.sln

      - name: Publish to folder
        run: msbuild learningapptest/learningapptest.sln /nologo /verbosity:m /t:Build /p:outdir=obj/Release/Package/PackageTmp/published

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v4
        with:
          name: ASP-app
          path: 'learningapptest/obj/Release/Package/PackageTmp/published/**'

  deploy:
    runs-on: windows-latest
    needs: build
    permissions:
      id-token: write #This is required for requesting the JWT
      contents: read #This is required for actions/checkout

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v4
        with:
          name: ASP-app
      
      - name: Login to Azure
        uses: azure/login@v2
        with:
          client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_F6348B2E31F94008973B341661415A87 }}
          tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_6F3985F493BC43D09123DC142720057F }}
          subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_8BE450D5FE7840ECB96C8E7C3E95A8A4 }}

      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v3
        with:
          app-name: 'learningapperik'
          slot-name: 'Production'
          package: .

          






I changed this:

    nuget restore

to:

    nuget restore learningapptest/learningapptest.sln

I also changed this:

    msbuild /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="\published\"

to:

    msbuild learningapptest/learningapptest.sln /nologo /verbosity:m /t:Build /p:outdir=obj/Release/Package/PackageTmp/published

Last, I changed this:

- name: Upload artifact for deployment job
        uses: actions/upload-artifact@v4
        with:
          name: ASP-app
          path: '/published/**'

to:

- name: Upload artifact for deployment job
        uses: actions/upload-artifact@v4
        with:
          name: ASP-app
          path: 'learningapptest/obj/Release/Package/PackageTmp/published/**'

Now, the github action was green after a build and deploy, but after going to my website, it was giving me a permissions issue, something like this: "You do not have permissions to view this page".

I then found out that in Azure, I had set my .NET version to .NET 4.8 Framework. So, I set it to .NET 8, which is the correct version.

I then recreated this .yml file in Azure:

# 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 - learningapperik

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: windows-latest
    permissions:
      contents: read #This is required for actions/checkout

    steps:
      - uses: actions/checkout@v4

      - name: Set up .NET Core
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '8.x'

      - 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@v4
        with:
          name: .net-app
          path: ${{env.DOTNET_ROOT}}/myapp

  deploy:
    runs-on: windows-latest
    needs: build
    permissions:
      id-token: write #This is required for requesting the JWT
      contents: read #This is required for actions/checkout

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v4
        with:
          name: .net-app
      
      - name: Login to Azure
        uses: azure/login@v2
        with:
          client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_A111F52FF5EE49A4AA670255A04E2CF6 }}
          tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_AC4F4514DC254B5F851B21E9BEB10418 }}
          subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_E8FF084E21B84CACB21A504E25D1F320 }}

      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v3
        with:
          app-name: 'learningapperik'
          slot-name: 'Production'
          package: .

          

Now, the build and publish steps were failing...

I then changed this:

dotnet build --configuration Release

to:

dotnet build learningapptest/learningapptest.sln --configuration Release

And, changed this:

dotnet publish -c Release -o "${{env.DOTNET_ROOT}}/myapp"

to:

dotnet publish learningapptest/learningapptest.sln -c Release -o "${{env.DOTNET_ROOT}}/myapp"

This is my final .yml file:

# 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 - learningapperik

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build:
    runs-on: windows-latest
    permissions:
      contents: read #This is required for actions/checkout

    steps:
      - uses: actions/checkout@v4

      - name: Set up .NET Core
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '8.x'

      - name: Build with dotnet
        run: dotnet build learningapptest/learningapptest.sln --configuration Release

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

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v4
        with:
          name: .net-app
          path: ${{env.DOTNET_ROOT}}/myapp

  deploy:
    runs-on: windows-latest
    needs: build
    permissions:
      id-token: write #This is required for requesting the JWT
      contents: read #This is required for actions/checkout

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v4
        with:
          name: .net-app
      
      - name: Login to Azure
        uses: azure/login@v2
        with:
          client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_A111F52FF5EE49A4AA670255A04E2CF6 }}
          tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_AC4F4514DC254B5F851B21E9BEB10418 }}
          subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_E8FF084E21B84CACB21A504E25D1F320 }}

      - name: Deploy to Azure Web App
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v3
        with:
          app-name: 'learningapperik'
          slot-name: 'Production'
          package: .

          

After all of that, my page would come up normally and was working 100%.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.