0

I'm working on a http-triggered azure function and testing locally. My azure function connects to sql database. I want to store connection strings somewhere (environment variables?) so that they do not show up in the code. And azure function can still access the connection strings like below:

server = os.getenv('SERVERNAME') 
database = os.getenv('DBNAME') 
username = os.getenv('DBUSER') 
password = os.getenv('PWD')

I created user environment variables (SERVERNAME, DBNAME, etc) on my local computer, but the azure function doesn't not seem to be able to access those.

Does anyone know how to set those environment variables so that my azure function can access the variables using os.getenv()? I'm on windows. Thanks.

1
  • you want to create an ARM template, and part of that deployment, you'd be fetching your secrets from key vault Commented Sep 23, 2020 at 3:26

1 Answer 1

3

You can refer to this official documentation.

enter image description here

If you develop azure function on the azure portal, you can store Environment variables in application settings.

If you develop azure function locally, you can store it in local.settings.json file.

Example

local.settings.json

enter image description here

I did a test, and found no problem.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.