Brlja
Brlja

Reputation: 404

How to use/remap Azure KeyVault secret as Azure DevOps Pipeline environment variable?

I'm storing database connection string in Azure KeyVault and would like to use / remap keyvault secret DB-DEV-CONNECTION-STRING to ASPNETCORE_ConnectionStrings__ConnectionString environment variable so my server can read it as configuration property during startup.

I'm using web configuration (not YAML) and don't know how to reference variable so that it is not called DB-DEV-CONNECTION-STRING but ASPNETCORE_ConnectionStrings__ConnectionString.
I have linked keyvault in my piplene and secret is succesfuly downloaded when build job starts.

I want something like this: enter image description here

Upvotes: 3

Views: 1173

Answers (1)

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41545

Add a PowerShell task after the key vault task and set the variable:

Write-Host "##vso[task.setvariable variable=ASPNETCORE_ConnectionStrings_ConnectionString]$(DB-DEV-CONNECTION-STRING)"

enter image description here

Upvotes: 1

Related Questions