title: Cannot authenticate when debugging Azure Functions in local with VS Code
body: <p>I have an <strong>Azure Function</strong> in Python where I'm getting a secret from <strong>Key Vault</strong>. The Azure Function is part of an <strong>App Service</strong> with <strong>Managed Identity</strong> configured, so I do not have a Service Principal. To access Key Vault, I'm using the azure identity library and the <strong>DefaultAzureCredential</strong> class.</p>
  <p>My issue is that <strong>with local debugging of this function, credentials are not detected</strong>. I know that the debugger use a different shell, so login environment variables are not set. I tried to specify the &quot;env&quot; property in launch.json but get a warning that I'm not allowed to add it, same thing if I rename it to &quot;environment&quot;. I also tried the InteractiveBrowserCredential class to login with my user account as a workaround, but then the credentials are dismissed as incorrect to access Key Vault.</p>
  <p>How could I setup my VS Code local debugging environment to work with the managed identity of App Service?</p>
  <p>Here is an except of my code:</p>
  <pre class="lang-py prettyprint-override"><code>import os
  import logging
  import azure.functions as func
  from azure.storage.blob import BlobServiceClient
  from azure.identity import DefaultAzureCredential, UsernamePasswordCredential
  from azure.keyvault.secrets import SecretClient
  
  def main(req: func.HttpRequest) -&gt; func.HttpResponse:
      vault_url = os.environ['KeyVaultUrl']
      credential = DefaultAzureCredential()
      secret_client = SecretClient(vault_url=vault_url, credential=credential)
      access_key = secret_client.get_secret(os.environ['StorageSecretName'])
  </code></pre>
  <p>Thank you</p>