title: Python best practice secrets for azure functions and other scripts
body: <p>I have a python project which contains an azure function and other scripts. The project structure is as follows:</p>
  <pre><code>__app__ 
   | - myAzureFunction
   | | - __init__.py
   | | - function.json
   | | - example.py
   | - scripts
   | | - myFirstScript.py
   | | - mySecondScript.py
   | - host.json 
   | - local.settings.json
   | - requirements.txt
  </code></pre>
  <p>During develeopment, I created the scripts first. They are accessing data from a blob storage. I stored all the secrets as environment variables. Now I have added an azure function and that requires the secrets to be stored in local.settings.json. Having them stored twice - as environment variables and in local.settings.json does not seem right to me. Is there a best practice for doing this?</p>
  <p>I tried</p>
  <pre><code>import os 
  settings = os.environment[&quot;someKey&quot;]
  </code></pre>
  <p>which works in myAzureFunction/<strong>init</strong>.py, but not in scripts/myFirstScript.py.</p>
  <p>I am aware of this solution <a href="https://docs.microsoft.com/en-us/azure/key-vault/secrets/quick-create-python?tabs=cmd" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/key-vault/secrets/quick-create-python?tabs=cmd</a> but that implies still two approaches: one for simple scripts and one for azure functions. I thought there might be a single uniform approach.</p>