I am getting below error while running pipeline from Azure DevOps (Using Terraform). I have defined a service connection which is used as Variable on the pipeline.
Error building ARM Config: obtain subscription() from Azure CLI: parsing json result from the Azure CLI: waiting for the Azure CLI: exit status 1: ERROR: Please run 'az login' to setup account.
Below is my YAML file
parameters:
environment: ''
environmentPath: ''
terraformStateFilename: ''
artifacts: ''
steps:
- task: TerraformInstaller@0
inputs:
terraformVersion: $(terraformVersion)
- task: TerraformCLI@0
displayName: Terraform Init
inputs:
provider: 'azurerm'
command: 'init'
workingDirectory: $(System.DefaultWorkingDirectory)/${{ parameters.environmentPath }}
backendServiceArm: $(subscription)
backendAzureRmResourceGroupName: $(terraformGroup)
backendAzureRmStorageAccountName: $(terraformStorageName)
backendAzureRmContainerName: $(terraformContainerName)
backendAzureRmKey: ${{ parameters.terraformStateFilename }}
- task: TerraformCLI@0
displayName: Terraform Plan
inputs:
provider: 'azurerm'
command: 'plan'
workingDirectory: $(System.DefaultWorkingDirectory)/${{ parameters.environmentPath }}
environmentServiceNameAzureRM: $(subscription)
commandOptions: '-out plan.tfplan'
- task: CopyFiles@2
inputs:
SourceFolder: '${{ parameters.environmentPath }}'
Contents: |
terraform.lock.hcl
versions.tf
providers.tf
plan.tfplan
terraform.tfvars
TargetFolder: '$(Build.ArtifactStagingDirectory)'
displayName: 'Copy Artifacts'
- publish: '$(Build.ArtifactStagingDirectory)'
artifact: ${{ parameters.artifacts }}
e