List blobs with Python

PeterP1550 80 Reputation points
2023-08-17T14:48:27.13+00:00

I need to get a list of the blobs in a container to get the file name to decrypt it. What is the syntax error?

error: invalid syntax

https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-list-python

def list_blobs_flat(self, blob_service_client: BlobServiceClient, 'containerDev/Students'):
    container_client = blob_service_client.get_container_client(container='containerDev/Students')

    blob_list = container_client.list_blobs()

    for blob in blob_list:
        print(f"Name: {blob.name}")

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,443 questions
{count} votes

Accepted answer
  1. ShaikMaheer-MSFT 38,521 Reputation points Microsoft Employee
    2023-08-18T07:32:28.0733333+00:00

    Hi PeterP1550,

    Thank you for posting query in Microsoft Q&A Platform.

    Yes, it seems there is a syntax error in your code. In the function definition of list_blobs_flat, you need to use parameter names. You used totally 3 parameters it seems. In which 2 are fine. But last parameter, instead of using parameter name, you used some string there with single quotes. Kindly check it and correct.

    User's image

    Also, if we are using Azure data factory service here then, we can consider using GetMetaData Activity.

    Hope this helps. Please let me know if any further queries.


    Please consider hitting Accept Answer button. Accepted answers help community as well.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.