question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Erroneous logging message when getting secrets.

See original GitHub issue
  • Package Name: azure-common==1.1.25 azure-core==1.8.0 azure-identity==1.4.0 azure-keyvault-certificates==4.1.0 azure-keyvault-keys==4.1.0 azure-keyvault-secrets==4.1.0 azure-storage-blob==12.3.2

  • Operating System: ubuntu 18.04

  • Python Version: Python 3.7.7 (default, Jun 9 2020, 18:08:39) [GCC 8.3.0] on linux

Describe the bug Using AKS with VMSS and an Azure Identity user assigned. Any time I get a secret I also get this message. This is a non-fatal event and the code retrieves the secret and continues on.

EnvironmentCredential.get_token failed: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.

No system variables are set for the azure credential authentication.

To Reproduce Steps to reproduce the behavior:

  1. AKS cluster with VMSS with user assigned identity no in same resource group as cluster.
  2. Launch python and get secret from azure vault.
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient

credential = DefaultAzureCredential()
secret_client = SecretClient(vault_url="https://XXXXXXX.vault.azure.net", credential=credential)
secret_client.get_secret('XXXXX').value

Expected behavior Secret without odd message that doesn’t make sense when not using environment variables.

Additional context I’m going to verify this happens with a base python container and report back.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chlowellcommented, Aug 12, 2020

Is there a way to disable warnings?

You could use logging to filter this particular warning. Here’s one way:

import logging
import sys

def filter_environment_credential_warning(record):
    if record.name.startswith("azure.identity") and record.levelno == logging.WARNING:
        message = record.getMessage()
        return not message.startswith("EnvironmentCredential.get_token")
    return True

handler = logging.StreamHandler(sys.stdout)
handler.addFilter(filter_environment_credential_warning)
logging.basicConfig(level=logging.INFO, handlers=[handler])

I am using dask and pulling credentials over and over again for each workers job.

Do you mean you’re creating multiple instances of DefaultAzureCredential?

0reactions
washcyclecommented, Aug 20, 2020

Gotcha, thanks.

I ended up pulling the credentials to a higher scope so the tasks would have them without having to fetch them again.

I wanted to keep the DefaultAzureCredential call because we use .env files for development and managed credentials for production and it doesn’t require any extra code to handle the different c onfigurations.

Thanks for clearing up the warning messages for me though @chlowell.

Read more comments on GitHub >

github_iconTop Results From Across the Web

6 Ways To Make Error Logs Your New Secret Weapon
Receiving an error that just tells you that “an error occurred master” can only cause panic. A good error log answers these questions:...
Read more >
Resolve Secrets Manager secret access errors after ... - AWS
I attempted to retrieve or access an AWS Secrets Manager secret, and received an error similar to one of the following:.
Read more >
How do I prevent secrets beeing logged in the PHP error log?
Option 1 - turn off error logging:​​ So, the solution here is to tell Craft to turn off PHP error logging (you also...
Read more >
Troubleshooting - Secrets Store CSI Driver - Kubernetes
Secrets Store CSI Driver is deployed as a DaemonSet. The above error indicates the CSI driver pods aren't running on the node. If...
Read more >
What does a “Shared secret is incorrect” error mean?
Invalid Message-Authenticator! (Shared secret is incorrect.) ... The Shared secret is incorrect error appears when the packet signature is wrong.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found