question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AzureCLI input connectedServiceNameARM references service connection $(azureServiceConnection) which could not be found

See original GitHub issue

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: AzureCLI@2

Environment

  • Azure DevOps Services

    • Account name: asset-toolbox
    • Team project name: container-app
    • Build definition name/build number: container-app-iac
  • Agent - Hosted (ubuntu-latest)

Issue Description

I am using AzureCLI@2 task to run a bicep script I configured the task to use a variable with the name of my service connection

- task: AzureCLI@2
  displayName: Azure Bicep
  inputs:
    azureSubscription: $(azureServiceConnection)
    scriptType: bash
    scriptLocation: inlineScript
    inlineScript: |
      az group create --name $(azureResourceGroup) --location $(azureLocation) --debug
      az deployment group create --resource-group $(azureResourceGroup) --template-file main.bicep --parameters acrName=$(azureContainerRegistry) clusterName=$(azureKubernetesName) sqlserverName=$(azureSqlServerName) kvName=$(azureKeyVaultName) loadTestName=$(azureLoadTestName) --debug

So I created a group variable containing the azureServiceConnection variable, but when I run the pipeline the task cannot interpret the variable’s value

image

If I create a global variable $(azureServiceConnection) inside my yml pipeline, everything works. The problem is when I try to use variable group

My variable group is configured without restrictions, any pipeline can access My service connection has pipeline permission confured

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
nnellanspdlcommented, Dec 6, 2022

Try defining which variable group you need per Stage, like so:

- stage: Stage_Deploy_DEV
  displayName: Stage Deploy DEV
  dependsOn: Stage_Build
  variables:
  - group: varGroupDev
  jobs:
  - deployment: Job_Deploy_DEV
    displayName: Job Deploy DEV
    pool:
      vmImage: $(vmImageName)
    environment: 'aks-containerapp-demo-dev.default'
    strategy:
      runOnce:
        deploy:
          steps:

- stage: Stage_Deploy_PRD
  displayName: Stage Deploy PRD
  dependsOn: Stage_Deploy_DEV
  variables:
  - group: varGroupPrd
  jobs:
  - deployment: Job_Deploy_PRD
    displayName: Job Deploy PRD
    pool:
      vmImage: $(vmImageName)
    environment: 'aks-containerapp-demo-prd.default'
    strategy:
      runOnce:
        deploy:
          steps:
1reaction
nnellanspdlcommented, Dec 6, 2022

Are you using the same pipeline for QA and PRD? If so, how are you selecting which environment the pipeline runs against?

Read more comments on GitHub >

github_iconTop Results From Across the Web

The service connection does not exist or has not been ...
Job Phase_1: Step AzureResourceGroupDeployment input ConnectedServiceName references service connection which could not be found.
Read more >
The pipeline is not valid. Job Job - step references a service ...
Job Job: Step AzureRmWebAppDeployment input ConnectedServiceName references service connection DEV-ResourceGroup-DEV_CHEM_SalesForce which could not be found.
Read more >
Can't Authorize YAML Build Task to Use Service Connection
Job Job: Step input azureSubscription references service connection My Subscription which could not be found. The service connection does not ...
Read more >
Service connections in Azure Pipelines
You can create a connection from Azure Pipelines to external and remote services for executing tasks in a job.
Read more >
Failed service connection - Resource Authorization issue
Job Job: Step SonarQubePrepare input SonarQube references service connection TotalVote Core which could not be found. The service connection ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found