How to Add and Use Environment Variables in Azure - CDCgov/prime-simplereport GitHub Wiki

The following steps will create an Azure-based environment variable and automatically make it available in each environment when the application is deployed.

  1. Add desired secrets to simple-report-global in Azure Key Vault. Make sure to affix -${env} to the name
  2. In ops/${env}/_data.tf in each respective environment folder, add a data entry with the secret’s name in Key Vault
  3. In ops/${env}/api.tf in each respective environment folder, add an environment variable to app_settings that points to the corresponding entry in that environment's _data.tf (the file you changed in step 2!).
  4. (Optional) Add an entry to application.yaml that refers to the newly-created environment variable from step 3. This is only necessary if you need to override the variable: for example, when leveraging a local environment.

The newly created variable can be accessed in any desired manner that is supported by the code. For example, leveraging the @Value or @ConfigurationProperties annotations is a useful approach for the backend Spring application.