@Vinodh247 Thanks for the answer Vindoh.
This is my yaml pipeline syntax and I dont thing that what you are recommending will work in this case.
I have created a service connection(principal) with the name of the azure container registry.
trigger:
- main
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: TerraformJob
displayName: 'Terraform Apply'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: TerraformInstaller@1
inputs:
terraformVersion: 'latest'
- task: TerraformTaskV4@4
inputs:
provider: 'azurerm'
command: 'init'
backendServiceArm: 'new-spfi'
backendAzureRmResourceGroupName: 'Hamza_Personal_project'
backendAzureRmStorageAccountName: 'aksterrdeployement'
backendAzureRmContainerName: 'akswli'
backendAzureRmKey: 'terraform.tfstate'
- task: TerraformTaskV4@4
inputs:
provider: 'azurerm'
command: 'plan'
commandOptions: '-out=tfplan'
environmentServiceNameAzureRM: 'new-spfi'
- task: TerraformTaskV4@4
inputs:
provider: 'azurerm'
command: 'apply'
commandOptions: 'tfplan'
environmentServiceNameAzureRM: 'new-spfi'
- job: Build
dependsOn: TerraformJob
displayName: Build
pool:
vmImage: 'ubuntu-latest'
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
containerRegistry: 'MineTeridtry'
repository: 'hamcontainerRegistry'
command: 'buildAndPush'
Dockerfile: '$(Build.SourcesDirectory)/frontend/Dockerfile'