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.
- Add desired secrets to
simple-report-globalin Azure Key Vault. Make sure to affix-${env}to the name - In
ops/${env}/_data.tfin each respective environment folder, add a data entry with the secret’s name in Key Vault - In
ops/${env}/api.tfin 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!). - (Optional) Add an entry to
application.yamlthat 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.