Ejemplo n.º 1
0
def upload_azure_blob(blob_path, filepath):
    client_id = os.environ["CLIENT_ID"]
    secret_key = os.environ["SECRET_KEY"]
    tenant_id = os.environ["TENANT_ID"]
    keyvault_account = os.environ['AZURE_KEYVAULT_ACCOUNT']

    storageaccountname = get_storage_account(blob_path)

    client = blobclient.BlobStorageClient(storageaccountname, client_id,
                                          tenant_id, secret_key,
                                          keyvault_account)

    client.upload_from_file(filepath, blob_uri=blob_path)
Ejemplo n.º 2
0
def download_azure_blob(blob_path, local_path):
    helpers.makedirs(local_path, isfile=True)

    client_id = os.environ["CLIENT_ID"]
    secret_key = os.environ["SECRET_KEY"]
    tenant_id = os.environ["TENANT_ID"]
    keyvault_account = os.environ['AZURE_KEYVAULT_ACCOUNT']

    storageaccountname = get_storage_account(blob_path)

    client = blobclient.BlobStorageClient(storageaccountname, client_id,
                                          tenant_id, secret_key,
                                          keyvault_account)

    client.download_to_path(local_path, blob_uri=blob_path)
Ejemplo n.º 3
0
def download_azure_blob(blob_path, local_path):
    client_id = os.environ["CLIENT_ID"]
    secret_key = os.environ["SECRET_KEY"]
    tenant_id = os.environ["TENANT_ID"]
    keyvault_account = os.environ['AZURE_KEYVAULT_ACCOUNT']

    try:
        os.makedirs(os.path.dirname(local_path))
    except OSError:
        pass

    storageaccountname = get_storage_account(blob_path)

    client = blobclient.BlobStorageClient(storageaccountname, client_id,
                                          tenant_id, secret_key,
                                          keyvault_account)

    client.download_to_path(local_path, blob_uri=blob_path)
Ejemplo n.º 4
0
def download_azure_blobs(prefix, local_dir):
    helpers.makedirs(local_dir)

    client_id = os.environ["CLIENT_ID"]
    secret_key = os.environ["SECRET_KEY"]
    tenant_id = os.environ["TENANT_ID"]
    keyvault_account = os.environ['AZURE_KEYVAULT_ACCOUNT']

    storage_account, container, blob_prefix = unpack_path(prefix)

    client = blobclient.BlobStorageClient(storage_account, client_id,
                                          tenant_id, secret_key,
                                          keyvault_account)

    for blob_uri in client.list_blobs(container_name=container,
                                      prefix=blob_prefix):
        download_to_path = os.path.join(local_dir, blob_uri.name)
        helpers.makedirs(download_to_path, isfile=True)

        download_uri = os.path.join(storage_account, container, blob_uri.name)

        client.download_to_path(download_to_path, blob_uri=download_uri)