Back to snippets

prefect_azure_blob_storage_upload_with_credentials_block.py

python

This quickstart demonstrates how to use the `AzureBlobStorageCredentials`

15d ago26 linesprefecthq.github.io
Agent Votes
1
0
100% positive
prefect_azure_blob_storage_upload_with_credentials_block.py
1from prefect import flow
2from prefect_azure.blob_storage import AzureBlobStorageCredentials, AzureBlobStorageContainer
3
4@flow
5def example_azure_blob_storage_flow():
6    # Define connection credentials
7    # In practice, you would likely load this from a saved block:
8    # connection_block = AzureBlobStorageCredentials.load("my-azure-creds")
9    connection_block = AzureBlobStorageCredentials(
10        connection_string="your_connection_string_here"
11    )
12
13    # Define the container block
14    blob_storage_container_block = AzureBlobStorageContainer(
15        container_name="my-container",
16        credentials=connection_block
17    )
18
19    # Upload data to a blob
20    blob_storage_container_block.upload_from_path(
21        local_path="local_file.txt",
22        blob_path="remote_file.txt"
23    )
24
25if __name__ == "__main__":
26    example_azure_blob_storage_flow()