azureazure-devopsazure-web-app-serviceazure-pipelinesazure-releases

How to install packet on Linux Azure App Service


I want to run my .net 5 app on a Linux app service that has specific libraries (for example ibnss3-dev).

I have pipeline for build:

trigger:
- main

pool:
  vmImage: ubuntu-20.04

variables:
  buildConfiguration: 'Release'
  wwwrootDir: 'Web/wwwroot'
  dotnetSdkVersion: '5.0.x'

- script: |
    sudo apt-get update
    sudo apt-get install -y libnss3-dev
  displayName: 'Dep install'

steps:
- task: UseDotNet@2
  displayName: 'Use .NET Core SDK $(dotnetSdkVersion)'
  inputs:
    version: '$(dotnetSdkVersion)'


- script: 'echo "$(Build.DefinitionName), $(Build.BuildId), $(Build.BuildNumber)" > buildinfo.txt'
  displayName: 'Write build info'
  workingDirectory: $(wwwrootDir)
  
- task: DotNetCoreCLI@2
  displayName: 'Restore project dependencies'
  inputs:
    command: 'restore'
    projects: '**/Web.csproj'

- task: DotNetCoreCLI@2
  displayName: 'Build the project - $(buildConfiguration)'
  inputs:
    command: 'build'
    arguments: '--no-restore --configuration $(buildConfiguration)'
    projects: '**/Web.csproj'

- task: DotNetCoreCLI@2
  displayName: 'Publish the project - $(buildConfiguration)'
  inputs:
    command: 'publish'
    projects: '**/Web.csproj'
    publishWebProjects: false
    arguments: '--no-build --configuration Release --output $(Build.ArtifactStagingDirectory)/Release'
    zipAfterPublish: true

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  condition: succeeded()

And a release with Azure App Service deploy (Task Version 4)

How should I do it? I tried the following solutions, but non of them works:

  1. Release Post Deployment Action with sudo (kuduPostDeploymentScript.sh: sudo: not found)
  2. Release Post Deployment Action without sudo ([error]E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied))
  3. Add script step in the pipeline

I can run install command manually via ssh but I'm looking for an automated method.

apt-get update
apt-get install -y libnss3-dev

Solution

  • Please check this question. As you already discovered you should replace your command "dotnet web.dll" with sh script where you first install dependencies and then run your web.dll with dotnet CLI.