title: How to check if a certain certificate is already present in a keyvault?
body: <p>In a nightly Azure pipelines build I have 2 tasks:</p>
  
  <ul>
  <li>First I delete and purge a self-signed certificate from a keyvault</li>
  <li>Then I import the same self-signed certificate into the keyvault</li>
  </ul>
  
  <p>The reason I do it is to ensure that there is a certain certificate <em>always</em> is available in the keyvault.</p>
  
  <p>Here is my current code:</p>
  
  <pre><code># purge the self-signed cert from the Keyvault to avoid conflict; ignore failures
  - task: AzureCLI@2
    inputs:
      azureSubscription: '${{ parameters.ArmConnection }}'
      scriptType: 'pscore'
      scriptLocation: 'inlineScript'
      continueOnError: true
      failOnStandardError: false
      powerShellErrorActionPreference: 'silentlyContinue'
      inlineScript: |
        az keyvault certificate delete --vault-name $(KeyVaultName) --id 'https://$(KeyVaultName).vault.azure.net/certificates/my-self-signed-cert'
        az keyvault certificate purge --vault-name $(KeyVaultName) --id 'https://$(KeyVaultName).vault.azure.net/deletedcertificates/my-self-signed-cert'
  
  # import the self-signed certificate my-self-signed-cert into the Keyvault
  - task: AzurePowerShell@5
    inputs:
      azureSubscription: '${{ parameters.ArmConnection }}'
      ScriptType: 'InlineScript'
      azurePowerShellVersion: '3.1.0'
      Inline: |
        $Pwd = ConvertTo-SecureString -String 'MyPassword' -Force -AsPlainText
        $Base64 = 'MIIKqQ____3000_CHARS_HERE______1ICAgfQ=='
        Import-AzKeyVaultCertificate -VaultName $(KeyVaultName) -Name my-self-signed-cert -CertificateString $Base64 -Password $Pwd
  </code></pre>
  
  <p>My question is:</p>
  
  <p>How could I please check if the certificate is maybe already available in the keyvault?</p>
  
  <p>(Because I use ARM templates and the resources keep running and are not deleted, while the pipeline is being run every evening).</p>
  
  <p>And if the certificate is there, how to skip the above 2 tasks (Azure-cli and the PowerShell)?</p>
  
  <p>I don't quite understand how to use conditionals in the pipelines YAML file.</p>