Contents
data/authors/Paul Logan.json

Automating application updates to the cloud

What started of as a small CRUD app I created to allow a manager to update and create new production targets, has gradually grown in functionality - just like any successful app should.

Previously, I was publishing to the Azure App Service directly from within VS COde, using the Azure App Service extension, easily found after installation by F1 => typing AASDWA (Azure App Service: Deploy to Web App).

As the updates to the app become more frequent, it was about time to set up an Azure deployment pipeline to deploy the code to the App Service.

The pipeline will be triggered by commits pushed to the repository.

Create the Pipeline

Head on over to the app in your Azure Devops => Pipelines => Create first pipeline => Save and Run

Do a git latest in VS Code to get the yml file.

Add a deployment step to CI pipeline based on this documentation.

/posts/coding/azure-devops-add-ci-pipeline/pipeline-run-error.png
Pipeline run error
/posts/coding/azure-devops-add-ci-pipeline/new-service-connection-1.png
Creating a Service Connection step 1
/posts/coding/azure-devops-add-ci-pipeline/new-service-connection-2.png
Creating a Service Connection step 2
/posts/coding/azure-devops-add-ci-pipeline/new-service-connection-3.png
Creating a Service Connection step 3
/posts/coding/azure-devops-add-ci-pipeline/new-service-connection-4.png
Creating a Service Connection step 4

trigger:
- main

pool:
  vmImage: ubuntu-latest

variables:
  buildConfiguration: 'Release'

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: Publish
  inputs:
    command: publish
    publishWebProjects: false
    projects: 'DataDoctor.csproj'
    arguments: '--configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    zipAfterPublish: true

- task: AzureWebApp@1
  inputs:
    azureSubscription: 'DataDoctorServiceConnection'
    appType: 'webApp'
    appName: 'DataDoctor'
    package: '$(Build.ArtifactStagingDirectory)/**/*.zip'
    deploymentMethod: 'auto'

Errors Overcome

There was a resource authorization issue: “The pipeline is not valid. Job Job: Step AzureWebApp input azureSubscription references YourConnectionName service connection which could not be found. The service connection does not exist, has been disabled or has not been authorized for use.”

Input required: ConnectedServiceName

No package found with specified pattern: /home/vsts/work/1/s/**/*.zipCheck if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.

Project file(s) matching the specified pattern were not found

Azure DevOps for ARM: Task failed while initializing. Error: Input required: ConnectedServiceName azureSubscription service-connection-name

Credits

Build, test, and deploy .NET Core apps Deploy to App Service using Azure Pipelines

https://stackoverflow.com/a/61891758/641165