The service connection does not exist or has not been authorized for use

Viewed 28660

I'm trying to create my first release pipeline, however I keep getting this error:

Exception Message: The pipeline is not valid. Job Phase_1: Step AzureResourceGroupDeployment input ConnectedServiceName references service connection which could not be found. The service connection does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz. (type PipelineValidationException)

I've tried to follow the instructions in the link, however the "Authorize Resources" button does not exist.

"Allow all pipelines to use this service connection" is already enabled and I have recreated the deployment task after enabling this.

How do I authorise the resource?

6 Answers

I had the same issue, and I initally missed the fact that you need to click the 'Authorize resources' button that appears, as shown below

enter image description here

Also in my case, my pipeline was missing variables that included the correct service connection name. These were set up in a variable group that was already being used by another pipeline. I needed to link them in my new pipeline:

Edit pipeline > select elipsis at top right > triggers > Variables > Variable groups > Link variable group

You can either use existing Service principal or create a new one. All you need is in documentation already. Create an Azure Resource Manager service connection using automated security

From Azure DevOps -> Project setting -> Service connection: Then click on "New Service Connection".Choose "Azure resource Manager" as type of service connection. Select Service Principal (Automatic). Run your pipeline

My "Service connection" which defined the service principal connection had been created separately to the task in my release pipeline.

In order for "Authorize Resources" to occur, you must create a new connection from the task itself (you may need to use the advanced options to add an existing service principal).

  1. under "Azure subscription" click the name of the subscription you wish to use
  2. Click the drop down next to "Authorize" and open advanced options
  3. Click " use the full version of the service connection dialog."
  4. Enter all your credentials and hit save

In "classic release pipelines", a release is a snapshot of a release pipeline, with all the settings of the pipeline materialized, and a deployment is the execution of a pipeline stage in the release.

In our case, a release generating this error during deployment predated a service principal renewal. We could edit the release to use the new service principal and successfully deploy the modified release. The release pipeline did not need modifications.

  1. Navigate to the release overview of the relevant release.
    • https://dev.azure.com/<user>/<project>/_releaseProgress?...
  2. Select Edit > Edit release.
  3. Click Edit tasks for the relevant stage.
  4. Select the Azure App Service Deploy step.
  5. Choose the correct Azure subscription and App Service name values.
    • These values will likely be the same as in the release pipeline
    • In our case these fields were empty and "needed attention".
  6. Click Save.
  7. Click Deploy.

The changes persist, so the corrected release can be deployed a second time without incident.

It is unclear whether this applies to YAML pipelines but I would guess no.

I was having this error because I was declaring the variable group containing the service connection name at stage level.

The error was fixed once I declared the variable group at pipeline level.

The admittely silly solution for me was to avoid declaring and using the Service Connection as a variable, i.e. in the case of connecting to an Azure Container Registry:

Failed

pool:
  vmImage: 'ubuntu-20.04'

variables:
  dockerRegistryServiceConnection: 'my-service-connection'
  baseContainerUrl: 'myregistry.azurecr.io/my_image:latest'

container:
  image: $(baseContainerUrl)
  endpoint: $(dockerRegistryServiceConnection)

Worked

pool:
  vmImage: 'ubuntu-20.04'

variables:
  baseContainerUrl: 'myregistry.azurecr.io/my_image:latest'

container:
  image: $(baseContainerUrl)
  endpoint: my-service-connection
Related