Join the Kedro community

Updated 2 months ago

Azure credentials setup issue with multiple values for keyword argument 'abs_creds'

At a glance

Hi i've setup my azure credentials as suggested but when i run the node I get "dict() got multiple values for keyword argument 'abs_creds'" does anyone know a potential reason with this ?

# hooks.py

from kedro.framework.hooks import hook_impl
from azure.keyvault.secrets import SecretClient
from azure.identity import DefaultAzureCredential


class AzureSecretsHook:
    @hook_impl
    def after_context_created(self, context) -> None:
        keyVaultName = "keyvault-0542abb"  # or os.environ["KEY_VAULT_NAME"] if you would like to provide it through environment variables
        KVUri = f"https://{keyVaultName}.vault.azure.net"

        my_credential = DefaultAzureCredential()
        client = SecretClient(vault_url=KVUri, credential=my_credential)

        secrets = {
            "abs_creds": "azure-blob-store",
            "s3_creds": "s3-bucket-creds",
        }
        azure_creds = {
            cred_name: client.get_secret(secret_name).value
            for cred_name, secret_name in secrets.items()
        }

        context.config_loader["credentials"] = {
            **context.config_loader["credentials"],
            **azure_creds,
        }

N
E
S
6 comments

>**context.config_loader["credentials"],
**azure_creds,


Does that keys exists in both?

no only in one credentials.yml is an empty file

i just tried to run the credentials from the file directly without the hook and got the same error

Long shot but perhaps try doing a constructive approach of fetching the credentials, directly modifying the context.config_loader might be causing the issue?

Something like:

existing_creds = context.config_loader.get("credentials", {})
merged_creds = {**existing_creds, **azure_creds}

Could you provide more details about your setup and the error, we'll try and recreate it on our end.

Add a reply
Sign up and join the conversation on Slack