[Python] dbutils secret issue for container url

Discussão em 'Python' iniciado por Stack, Março 31, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to access a blob storage like this and it works

    from azure.storage.blob import ContainerClient

    storage_account_name ='storage_account_name'
    storage_container_name = 'storage_container_name'
    sas_token = 'sv=<>&si=<>&sr=<>&sig=<>'

    account_url = "https://"+storage_account_name+".blob.core.windows.net/"+storage_container_name+"?"+sas_token

    container_client = ContainerClient.from_container_url(container_url=account_url)

    blobs = container_client.list_blobs()

    for blob in blobs:
    print(blob)


    But if I get the secret through dbutils and try to pass it through, it does not.

    from azure.storage.blob import ContainerClient

    storage_account_name ='storage_account_name'
    storage_container_name = 'storage_container_name'
    sas_token = dbutils.secrets.get(scope=secret_scope,key='some_key')

    account_url = "https://"+storage_account_name+".blob.core.windows.net/"+storage_container_name+"?"+sas_token

    container_client = ContainerClient.from_container_url(container_url=account_url)

    blobs = container_client.list_blobs()

    for blob in blobs:
    print(blob)


    Is it possible to keep on using dbutils and make it work

    Continue reading...

Compartilhe esta Página