title: Parameterized variable names as task input in Azure Pipelines
body: <p>I've been trying to make a YAML template that first uses the AzureKeyVault@1 task to get the value ofsome Azure KeyVault secrets, and then uses these secrets for the sqlUsername and sqlPassword in asqlAzureDacpacDeployment@1 task.</p>
  
  <p>I want to make the names of the KeyVault secrets a parameter, so that this template can be used for many different situations.</p>
  
  <p>I've successfully used this technique before, with an AzureKeyVault@1 task and then an AzurePowerShell@4 task, where the secret gets injected as an environment variable for the PowerShell script.</p>
  
  <p>This is a dressed down version of the working template:</p>
  
  <pre><code>parameters:
  - name: subscription
    type: string
  - name: keyVaultSecretName
    type: string
  - name: keyVault
    type: string
  jobs:
  - job: Run_PowerShell_With_Secret
    pool:
      name: Azure Pipelines
      vmImage: windows-latest
    steps:
    - task: AzureKeyVault@1
      inputs:
        azureSubscription: ${{ parameters.subscription }}
        keyVaultName:  ${{ parameters.keyVault }}
        secretsFilter: ${{ parameters.keyVaultSecretName }}
    - task: AzurePowerShell@4
      inputs:
        azureSubscription: ${{ parameters.subscription }}
        ScriptPath: 'some_script.ps1'
        azurePowerShellVersion: LatestVersion
      env: 
        SECRETVALUE: $(${{ parameters.keyVaultSecretName }})
  </code></pre>
  
  <p>And here is the template where I can't get the same technique to work:</p>
  
  <pre><code>parameters:
  - name: subscription
    type: string
  - name: keyVault
    type: string
  - name: sqlServerName
    type: string
  - name: sqlDatabaseName
    type: string
  - name: sqlServerAdminSecretName
    type: string
  - name: sqlServerPasswordSecretName
    type: string
  - name: dacpacName
    type: string
  - name: artifactName
    type: string
  jobs:
  - job: Deploy_SQL_Database
    pool:
      name: Azure Pipelines
      vmImage: windows-latest
    steps:
    - task: DownloadPipelineArtifact@2
      inputs:
        artifact: ${{ parameters.artifactName }}_artifacts
    - task: AzureKeyVault@1
      inputs:
        azureSubscription: ${{ parameters.subscription }}
        keyVaultName:  ${{ parameters.keyVault }}
        secretsFilter: '${{ parameters.sqlServerAdminSecretName }}, ${{ parameters.sqlServerPasswordSecretName }}'
    - task: sqlAzureDacpacDeployment@1
      inputs:
        azureSubscription: ${{ parameters.subscription }}
        ServerName: ${{ parameters.sqlServerName }}.database.windows.net
        DatabaseName: ${{ parameters.sqlDatabaseName }}
        sqlUsername: $(${{ parameters.sqlServerAdminSecretName }})
        sqlPassword: $(${{ parameters.sqlServerPasswordSecretName }})
        DacpacFile:  $(Pipeline.Workspace)\${{ parameters.dacpacName }}.dacpac
  </code></pre>
  
  <p>I can get the template to work if I hardcode the secret names:</p>
  
  <pre><code>parameters:
  - name: subscriptionName
    type: string
  - name: keyVault
    type: string
  - name: sqlServerName
    type: string
  - name: sqlDatabaseName
    type: string
  - name: dacpacName
    type: string
  - name: artifactName
    type: string
  jobs:
  - job: Deploy_${{ parameters.sqlDatabaseName }}_Database
    pool:
      name: Azure Pipelines
      vmImage: windows-latest
    steps:
    - checkout: none
    - task: AzureKeyVault@1
      inputs:
        azureSubscription: ${{ parameters.subscriptionName }}
        keyVaultName:  ${{ parameters.keyVault }}
        secretsFilter: 'SQLServerAdmin, SQLServerPassword'
    - task: DownloadPipelineArtifact@2
      inputs:
        artifact: ${{ parameters.artifactName }}_artifacts
    - task: sqlAzureDacpacDeployment@1
      inputs:
        azureSubscription: ${{ parameters.subscriptionName }}
        ServerName: ${{ parameters.sqlServerName }}.database.windows.net
        DatabaseName: ${{ parameters.sqlDatabaseName }}
        sqlUsername: $(sqlServerAdmin)
        sqlPassword: $(sqlServerPassword)
        DacpacFile:  $(Pipeline.Workspace)\${{ parameters.dacpacName }}.dacpac
  </code></pre>
  
  <p>Although this works for us for now, I find this sub-optimal. Is there any way I can make these parameterized variable names work?</p>