Search code examples
azure-devopsazure-web-app-serviceazure-pipelinesazure-pipelines-yamlabp-framework

Azure DevOps - How to find working directory path for specific zip file?


I am having trouble figuring out how to use YAML to add my API to Azure APP Service.

More specifically, how do I set the path up to find my HttpApi.Host.zip folder?

For reference I am following ABP.io tutorial at ABP Goes Azure. Step 6 of this tutorial is not applicable since it's a new Azure Dev Ops project, and they have eliminated the use of the Releases button.

I did make a pull request to notify them, but as busy as they are I doubt it gets address quickly.

Below is my YAML setup and Picture showing the Artifact files created. I have this task setup at the end of the run.

I have tried to do the following to allow it to find the zip file:

packageForLinux: '$(System.DefaultWorkingDirectory)/**/HttpApi.Host.zip'
packageForLinux: '$(System.DefaultWorkingDirectory)/**/Navrae.CentralWage.HttpApi.Host.zip'
packageForLinux: '$(System.DefaultWorkingDirectory)/*src/Navrae.CentralWage.HttpApi.Host.zip'
packageForLinux: '$(System.DefaultWorkingDirectory)/*drop/Navrae.CentralWage.HttpApi.Host.zip'

YAML file

- task: AzureRmWebAppDeployment@4
  displayName: Push Azure Api
  inputs:
    ConnectionType: 'AzureRM'
    azureSubscription: 'Azure Subscription removed'
    appType: 'webApp'
    WebAppName: 'WebAppAi'
    packageForLinux: '$(System.DefaultWorkingDirectory)/**/*.zip'

Here is my Artifacts produced: Should I be trying to target the Navrae.CentralWage.HttpApi.Host.zip? or do I have this confused?

Artifact file structure.

I will end up needing to do the same thing with the Blazor app, which I suspect will be easier once I figure this step out!


Solution

  • I checked the tutorial and found that in step 4, you build and output the file to the Build.ArtifactStagingDirectory folder. So, the path of Navrae.CentralWage.HttpApi.Host.zip is $(Build.ArtifactStagingDirectory)/Navrae.CentralWage.HttpApi.Host.zip

    The System.DefaultWorkingDirectory is local path on the agent where your source code files are downloaded. For example: c:\agent_work\1\s.

    The Build.ArtifactStagingDirectory is local path on the agent where any artifacts are copied to before being pushed to their destination. For example: c:\agent_work\1\a.

    They are different paths and this is why you can't find the file in System.DefaultWorkingDirectory. You can refer predefined variables for more details.

    The modified yaml looks like this:

    - task: DotNetCoreCLI@2
      displayName: Dotnet publish
      inputs:
        command: publish
        publishWebProjects: True
        arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
        zipAfterPublish: True
    
    - task: PublishBuildArtifacts@1
      displayName: Publish artifact
      inputs:
        PathtoPublish: '$(build.artifactstagingdirectory)'
      condition: succeededOrFailed()
    
    - task: AzureRmWebAppDeployment@4
      displayName: Push Azure Api
      inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: 'Azure Subscription '
        appType: 'webApp'
        WebAppName: 'WebAppAi'
        packageForLinux: '$(Build.ArtifactStagingDirectory)/Navrae.CentralWage.HttpApi.Host.zip'
    

    If you deploy the app directly and will not use the published Build Artifacts later (for example, use it in the classic release pipeline in step 6), the PublishBuildArtifacts@1 task can be skipped.

    By the way, you said "Step 6 of this tutorial is not applicable since it's a new Azure Dev Ops project, and they have eliminated the use of the Releases button."

    If you want the Releases button back and use the classic release pipeline, you can enable creation of classic pipelines by turning off a toggle at either organization level or project level. To manage it at organization level, navigate to your Organization settings, then under the Pipelines section choose Settings. In the General section, disable the Disable creation of classic build and classic release pipelines. To manage it at organization level, you need Project Collection Administrator rights, while for a project, you need Project Administrator rights.

    enter image description here

    Then you can follow the step 6 in the tutorial without problem.