-
Notifications
You must be signed in to change notification settings - Fork 648
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
385 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
from azure.storage.blob import BlobServiceClient | ||
|
||
def load_blob_file_paths_from_azure(storage_account_name, container_name, parent_path, sas_token, predicate=lambda x: True): | ||
|
||
def load_blob_file_paths_from_azure( | ||
storage_account_name, | ||
container_name, | ||
parent_path, | ||
sas_token, | ||
predicate=lambda x: True, | ||
): | ||
# Construct the account URL with the SAS token | ||
account_url = f"https://{storage_account_name}.blob.core.windows.net" | ||
# Service client to connect to Azure Blob Storage using SAS token | ||
blob_service_client = BlobServiceClient( | ||
account_url=account_url, | ||
credential=sas_token | ||
account_url=account_url, credential=sas_token | ||
) | ||
# Get a reference to the container | ||
container_client = blob_service_client.get_container_client(container_name) | ||
# List blobs in the directory | ||
blob_list = container_client.list_blobs(name_starts_with=parent_path) | ||
file_url_list = [f"{account_url}/{container_name}/{blob.name}?{sas_token}" for blob in blob_list if predicate(blob.name)] | ||
return file_url_list | ||
file_url_list = [ | ||
f"{account_url}/{container_name}/{blob.name}?{sas_token}" | ||
for blob in blob_list | ||
if predicate(blob.name) | ||
] | ||
return file_url_list |
Oops, something went wrong.