0
votes

I am using ubuntu-latest as my build vmImage for building all of my containers in my pipeline. Now I am trying to deploy a previously built container to AKS.

According to the documentation, it is supposed to look like this:

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Build
  jobs:
  - deployment: Deploy
    displayName: Deploy job
    pool:
      vmImage: $(vmImageName)

Unfortunately, there is no description of what the variable $(vmImageName) refers to, and following the steps is no longer possible, since using the visual interface uses Helm, which would confuse me even more.

I am building the container like this:

- job: BuildSQL
  displayName: Build SQL Server Container image
  pool:
    vmImage: "ubuntu-latest"
  steps:
    - task: Docker@2
      displayName: Build an image
      inputs:
        command: buildAndPush
        dockerfile: "$(Build.SourcesDirectory)/Code/Database/Docker/Dockerfile"
        arguments: -o $(Build.ArtifactStagingDirectory)/xxx.sql.tar
        containerRegistry: $(dockerRegistryServiceConnection)
        repository: his.sql
        tags: |
          $(tag)
    #publish the results of the previous task as manifest to be picked up by the deployment job
    - task: PublishPipelineArtifact@1
      inputs:
        artifactName: 'his.sql.tar'
        path: $(Build.ArtifactStagingDirectory)

During the next stage, if want to pick up the artifact and then deploy it:

 - stage: DeploySQL
    displayName: 'Deploy SQL Container to AKS'
    dependsOn: BuildSQL
    jobs:
    - deployment: Deploy
      displayName: Deploy job
      pool:
        vmImage: "ubuntu-latest"
      environment: 'sql-test.default'
      strategy:
        runOnce:
          deploy:
            steps:
            - task: DownloadPipelineArtifact@2
              inputs:
                artifactName: 'manifests'
                downloadPath: '$(Build.ArtifactStagingDirectory)/xxx.sql.tar'

The deployment job then fails with the following error message:

##[error]Pipeline does not have permissions to use the referenced pool(s) . For authorization details, refer to https://aka.ms/yamlauthz.

I am at a loss here and don't know what the pool actually refers to and what to enter there. How can I push this to my provisioned AKS cluster in Azure?

2

2 Answers

1
votes

I think this might help. If you don't have a strong preference for ubuntu-latest, then don't specify a vmImage at all! Microsoft will supply a private pool with no demands.

https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=example%2Cparameter-schema#pool

If you do have specific demands, you can add the demands: line to your 'pool` section.

https://docs.microsoft.com/en-us/azure/devops/pipelines/process/demands?view=azure-devops&tabs=yaml

1
votes

The issue actually could be with quotes you have here vmImage: "ubuntu-latest", please try change it to vmImage: 'ubuntu-latest'.

In terms of passing pool as variable you should keep in mind that:

Use only global level variables for defining a pool name. Stage/job level variables are not supported to define pool name.

However, if my first advice doesn't help please check this article.

As you may need to permission to Default pool

enter image description here