Accessing Azure Key Vault ‘secrets’ locally for Environment Variables – C#

How do I access my Azure Key Vault’s “secrets” locally, to be used as environment variables?

I have an integration test application which loads some secrets from a Settings.runsettings file where the secrets are currently defined as Environment Variables. My Settings.runsettings file currently looks like this:

<RunSettings>
  <RunConfiguration>
    .....
    <EnvironmentVariables>
      <MySecret>this needs to be removed and replaced with an Azure Key Vault secret reference</MySecret>
    </EnvironmentVariables>
  ....
  </RunConfiguration>
</RunSettings>

I need to remove all secrets from source control, so the ‘value’ of MySecret needs to be replaced with a secret reference from my Azure Key Vault. I checked this reference but it’s not clear to me how exactly I’m supposed to reference my Azure Key Vault and get the value of “MySecret” for app startup in my Settings.runsettings file.

Read more here: Source link