I am facing an issue in using deployment tokens stored in Key Vault for deploying the azure static web app. Since I am using different agents for fetching secrets from Key Vault and deploying the azure static web app, I need to pass the token from one job to another.
Job 1 - Get the Deployment token from Key Vault and use a bash command to verify
- job: GetDeploymentToken
pool:
name: 'Agent1'
timeoutInMinutes: 0
steps:
- task: AzureCLI@2
name: FetchSecret
inputs:
azureSubscription: 'service-connection'
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
$deploymenttoken = az keyvault secret show --name "deploymenttoken" --vault-name "dev1-keyvault" --query "value"
echo "##vso[task.setvariable variable=deploymenttoken ;isOutput=true]$deploymenttoken "
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
# Write your PowerShell commands here.
echo $(FetchSecret.deploymenttoken )
Job 2 - Use the variable deploymenttoken
- job: Deploy_Static_web_app
dependsOn: GetDeploymentToken
variables:
- name: deploymenttoken
value: $[ dependencies.GetDeploymentToken.outputs['FetchSecret.deploymenttoken'] ]
pool:
vmImage: ubuntu-latest
timeoutInMinutes: 0
steps:
- task: Bash@3
inputs:
targetType: 'inline'
arguments:
script: |
echo "1- $(deploymenttoken)"
- task: AzureStaticWebApp@0
inputs:
app_location: "frontend"
api_location: "api"
output_location: "build"
env:
azure_static_web_apps_api_token: '$(deploymenttoken)'
I am getting the below error:
Instead of fetching value from a different job, If I get the value from a library group, the deployment works fine
I tried using a dummy value in the library group and updating its value in job 1 using $env:deploymenttoken but even that didn't work