Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The method for managing timeout when using Python SDK to upload a blob in Azure Storage is to set the timeout parameter in the BlobServiceClient or the BlobClient constructor. The timeout parameter specifies the number of seconds the SDK will wait for the operation to complete before timing out.

For example, to set a timeout of 10 seconds when uploading a blob using the BlobClient, you can use the following code:

from azure.storage.blob import BlobServiceClient, BlobClient

blob_service_client = BlobServiceClient.from_connection_string("<your_connection_string>")
blob_client = blob_service_client.get_blob_client(container="<your_container_name>", blob="<your_blob_name>", timeout=10)

with open("path/to/local/file", "rb") as data:
    blob_client.upload_blob(data)

In this example, the timeout parameter is set to 10 seconds. If the upload operation takes longer than 10 seconds to complete, the SDK will raise a TimeoutError exception.