skip to Main Content

I’m trying to setup CI for my web app and I have the pipeline setup in ADO, but I don’t see my changes reflecting on the web app. I suspect I don’t have my YAML file configured and not sure which example is the best for me to follow.

  • Publishing model – Code
  • Runtime Stack – Dotnet – v6.0
  • Windows

https://learn.microsoft.com/en-us/azure/app-service/deploy-azure-pipelines?view=azure-devops&tabs=yaml

2

Answers


  1. Chosen as BEST ANSWER

    I was able to get this working.

    One thing I found was that my virtual directory was configured to the wrong location. It needed to be sitewwwroot. I also needed to update my YAML to $(Build.SourcesDirectory )/src and includeRootFolder = false


  2. In order to deploy the .Net 6.0 app correctly via Azure Devops yaml pipeline, Refer the steps below:-

    I pushed my code to Azure Repos like below:-

    enter image description here

    Click on 1)Set up build > Starter Pipeline OR 2)Pipelines on the left > New Pipeline > Azure repos git > Select your Azure repository that contains the .Net 6.0 App. > Starter Pipeline:-

    Add the below YAML pipeline for the Web app deployment:-

    trigger:
      branches:
        include:
          - main
    
    jobs:
    - job: Build
      displayName: 'Build and Publish'
      pool:
        vmImage: 'ubuntu-latest'
      steps:
      - task: UseDotNet@2
        displayName: 'Install .NET Core SDK'
        inputs:
          version: '6.x'
    
      - task: DotNetCoreCLI@2
        displayName: 'Restore Dependencies'
        inputs:
          command: 'restore'
          projects: '**/*.csproj'
    
      - task: DotNetCoreCLI@2
        displayName: 'Build Project'
        inputs:
          command: 'build'
          projects: '**/*.csproj'
          arguments: '--configuration Release'
    
      - task: DotNetCoreCLI@2
        displayName: 'Publish Project'
        inputs:
          command: 'publish'
          projects: '**/*.csproj'
          publishWebProjects: true
          arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)'
          zipAfterPublish: true
    
      - task: PublishPipelineArtifact@1
        displayName: 'Publish Artifact'
        inputs:
          targetPath: '$(Build.ArtifactStagingDirectory)'
          artifactName: 'publishedApp'
          publishLocation: 'pipeline'
    
    - job: Deploy
      displayName: 'Deploy to Azure Web App'
      dependsOn: Build
      pool:
        vmImage: 'ubuntu-latest'
      steps:
      - download: current
        artifact: 'publishedApp'
    
      - task: UseDotNet@2
        displayName: 'Install .NET Core SDK'
        inputs:
          version: '6.x'
    
      - task: AzureWebApp@1
        displayName: 'Azure Web App Deploy'
        inputs:
          azureSubscription: 'xxx subscription (xxxxxxfd-e2b6exxxxxxx2a7)'
          appType: 'webApp'
          appName: 'valeywebapp'
          package: '$(Agent.BuildDirectory)/**/*.zip'
          deploymentMethod: 'auto'
    
    

    enter image description here

    Click on Save and run and Save and run to run the pipeline, The Web app will be deployed to Azure Web app successfully like below:-

    Output:-

    enter image description here

    enter image description here

    Now, I made a change in my **.Net 6.0 Web app** and visit the previous pipeline > Click on run new > the deployment got triggered successfully:-

    enter image description here

    enter image description here

    enter image description here

    Output:-

    enter image description here

    enter image description here

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