0
votes

I try to set up a release pipeline for my Azure function. It's a v2 (.NET Core) project. Locally it works just fine, so I'd like to deploy it to Azure via DevOps.

I created the build pipeline with the standard steps (dotnet restore, dotnet build, etc.). It goes through fine and creates the artifact.

But I struggle to set up correctly the deployment. The pipeline has three tasks:

  1. Stop Azure App Service
  2. Deploy Azure App Service (I selected the Subscription, Function App as App type and the target App service).
  3. Start Azure App Service

The second step fails, and I get the following error message:

Failed to deploy web package to App Service.

If I click on the more detailed log, I get this:

2019-02-04T02:25:43.4893738Z ##[error]Failed to deploy web package to App Service.
2019-02-04T02:25:43.4905786Z ##[error]Error: (2/4/2019 2:25:42 AM) An error occurred when the request was processed on the remote computer.

The content of azure-ci.yaml:

resources:
- repo: self
queue:
  name: Hosted VS2017

steps:
- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore

    projects: '$(Parameters.RestoreBuildProjects)'


- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    projects: '$(Parameters.RestoreBuildProjects)'

    arguments: '--configuration $(BuildConfiguration)'


- task: DotNetCoreCLI@2
  displayName: Test
  inputs:
    command: test

    projects: '$(Parameters.TestProjects)'

    arguments: '--configuration $(BuildConfiguration)'


- task: DotNetCoreCLI@2
  displayName: Publish
  inputs:
    command: publish

    publishWebProjects: false

    projects: '$(Parameters.RestoreBuildProjects)'

    arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'


- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'

My questions are:

  • What do I miss for the deployment task?
  • Could it be something with the build pipeline? So the build artifact is "not in the right format", currently it's a ZIP file
  • Do I need the separate stop / start tasks or they are included in the deployment already?
1
It would be great if you can post your yaml file for the build pipeline - Low Flying Pelican
@LowFlyingPelican I updated the description, it's there - Szeki
You may need to change the "PathtoPublish: $(build.artifactstagingdirectory)" to "PathtoPublish: $(build.artifactstagingdirectory)/Release" in your last step. - Low Flying Pelican
@LowFlyingPelican I tried, but it doesn't help, the build fails as Not found PathtoPublish: D:\a\1\a\Release - Szeki
Can you try disabling the stop / start steps? - Low Flying Pelican

1 Answers

0
votes

Try the latest 4.x Azure App Service Deploy task. It uses Run From Package by default, which enforces the atomicity of project deployed on Azure and could avoid many troubles.