Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net 6 to Linux app service - incorrect KuduSync command generated #3437

Closed
jkewley opened this issue Feb 10, 2023 · 1 comment
Closed

.Net 6 to Linux app service - incorrect KuduSync command generated #3437

jkewley opened this issue Feb 10, 2023 · 1 comment

Comments

@jkewley
Copy link

jkewley commented Feb 10, 2023

I am trying to deploy a .Net 6 web api to a Linux app service in Azure using a YAML pipeline in Azure DevOps. My pipeline was working fine until I changed the file structure a bit (renamed the top-level folder from project to projectWebAPI). The first time I ran the pipeline after the rename everything worked fine. However, after making an inconsequential tweak to the code the pipeline began to fail during subsequent deployments at the kudu sync step.

Got service connection details for Azure App Service:'my-appsvc'
Package deployment using ZIP Deploy initiated.
Updating submodules.
Preparing deployment for commit id '111111-3'.
PreDeployment: context.CleanOutputPath False
PreDeployment: context.OutputPath /home/site/wwwroot
Generating deployment script.
Using cached version of deployment script (command: 'azure -y --no-dot-deployment -r "/tmp/zipdeploy/extracted" -o "/home/site/deployments/tools" --basic --sitePath "/tmp/zipdeploy/extracted/My ADO Project Name"').
Running deployment command...
Command: "/home/site/deployments/tools/deploy.sh"
Handling Basic Web Site deployment.
Error: From directory doesn't exist
An error has occurred during web site deployment.
Kudu Sync failed
\n/opt/Kudu/Scripts/starter.sh "/home/site/deployments/tools/deploy.sh"
Deployment Failed. deployer = VSTS_ZIP_DEPLOY deploymentPath = ZipDeploy. Extract zip.
##[error]Failed to deploy web package to App Service.

I spent quite a bit of time rolling code back and searching for an answer to no avail. I changed from AzureWebApp@1 to AzureRmWebAppDeployment@4 which didn't help. I finally stumbled across this issue where someone was reporting the same error that I was seeing : Error: From directory doesn't exist​.

So I crawled through the code in this repo and in the KuduSync one, and finally determined that the generated --sitePath parameter was incorrect. My package was being unzipped to /extracted and not /extracted/My ADO Project Name. I tried nuking my generated deploy.sh file but it kept generating the same sitePath parameter. Finally, I edited the generated deploy.sh file directly using VIM in the Kudu console and my deployments began to work.

I don't know what I've configured to cause the script generator to include the name of my AZDO project in the assumed extraction path. Looking at the code it defaults to '.', so something must be passing in the name of the AZDO project. At one point I had the 'deployment center' for my app service hooked up to Azure DevOps which I thought could be the link, but removing it didn't help.

This feels like a bug to me, but I'm not sure so here I am posting about it.

My rather mundane pipeline yaml:

[snip]
stages:
- stage: Build
  jobs:
  - job: BuildFrontEnd
    displayName: Build Front End
    pool:
      vmImage: $(vmImageName)

    steps:
    - task: Npm@1
      displayName: 'Npm install'
      inputs:
        workingDir: '$(System.DefaultWorkingDirectory)/ReactUI'
        command: 'install'
    - task: Npm@1
      displayName: 'Npm run build'
      inputs:
        workingDir: '$(System.DefaultWorkingDirectory)/ReactUI'
        command: 'custom'
        customCommand: 'run build'
    - task: ArchiveFiles@2
      displayName: 'Archive ReactUI/dist'
      inputs:
        rootFolderOrFile: '$(System.DefaultWorkingDirectory)/ReactUI/dist'
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/ReactUI/$(Build.BuildId).zip
        replaceExistingArchive: true
    - task: PublishPipelineArtifact@1
      displayName: 'Upload frontEnd artifact'
      inputs:
        targetPath: $(Build.ArtifactStagingDirectory)/ReactUI/$(Build.BuildId).zip
        artifact: frontEnd

  - job: BuildAPI
    displayName: 'Build API'
    dependsOn: BuildFrontEnd
    pool:
      vmImage: $(vmImageName)

    steps:
    - download: current
      displayName: Download frontEnd artifact
      artifact: frontEnd
    - task: ExtractFiles@1
      displayName: Extract frontEnd artifact
      inputs:
        archiveFilePatterns: '$(Pipeline.Workspace)/frontEnd/*.zip'
        destinationFolder: '$(System.DefaultWorkingDirectory)/WebAPI/ProjectNameHere/wwwroot'
        cleanDestinationFolder: true
        overwriteExistingFiles: true
    - script: dotnet build --configuration $(buildConfiguration)
      displayName: 'dotnet build $(buildConfiguration)'
      workingDirectory: '$(System.DefaultWorkingDirectory)/WebAPI/ProjectNameHere'
    - task: DotNetCoreCLI@2
      displayName: dotnet publish for Release
      inputs:
        workingDirectory: '$(System.DefaultWorkingDirectory)/WebAPI/ProjectNameHere'
        command: 'publish'
        arguments: '--configuration $(buildConfiguration) --output $(build.artifactStagingDirectory)/webAppRelease'
        publishWebProjects: true
        zipAfterPublish: true

    - task: PublishPipelineArtifact@1
      displayName: 'Upload webApi artifact'
      inputs:
        targetPath: '$(Build.ArtifactStagingDirectory)/webAppRelease/SalesforceImporterWebAPI.zip'
        artifact: webApi

- stage: Deploy

  dependsOn: Build
  condition: succeeded('Build')
  jobs:
  - job: DeployWebApi
    displayName: Deploy WebAPI (and front end files)
    steps:
    - download: current
      displayName: Download webApi artifact
      artifact: webApi
    - task: AzureRmWebAppDeployment@4
      inputs:
        azureSubscription: $(azureSubscription)
        appType: webAppLinux
        WebAppName: $(webAppName)
        StartupCommand: dotnet SalesforceImporterWebAPI.dll
        packageForLinux: '$(Pipeline.Workspace)/webApi/ProjectNameHere.zip'
@jvano
Copy link
Member

jvano commented Apr 29, 2024

Hi

If the problem persists and is related to running it on Azure App Service, please open a support incident in Azure:
https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request

This way we can better track and assist you on this case

Thanks,

Joaquin Vano
Azure App Service

@jvano jvano closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants