Get blob properties azure python
Skip to main content This browser is no longer supported. Show
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
BlobProperties Class
In this articleInheritanceazure.storage.blob._shared.models.DictMixin Constructor
Variablesname str The name of the blob. container str The container in which the blob resides. snapshot str Datetime value that uniquely identifies the blob snapshot. blob_type String indicating this blob's type. metadata dict Name-value pairs associated with the blob as metadata. last_modified datetime A datetime object representing the last time the blob was modified. etag str The ETag contains a value that you can use to perform operations conditionally. size int The size of the content returned. If the entire blob was requested, the length of blob in bytes. If a subset of the blob was requested, the length of the returned subset. content_range str Indicates the range of bytes returned in the event that the client requested a subset of the blob. append_blob_committed_block_count int (For Append Blobs) Number of committed blocks in the blob. is_append_blob_sealed bool Indicate if the append blob is sealed or not. New in version 12.4.0. page_blob_sequence_number int (For Page Blobs) Sequence number for page blob used for coordinating concurrent writes. server_encrypted bool Set to true if the blob is encrypted on the server. content_settings ContentSettings Stores all the content settings for the blob. blob_tier StandardBlobTier Indicates the access tier of the blob. The hot tier is optimized for storing data that is accessed frequently. The cool storage tier is optimized for storing data that is infrequently accessed and stored for at least a month. The archive tier is optimized for storing data that is rarely accessed and stored for at least six months with flexible latency requirements. rehydrate_priority str Indicates the priority with which to rehydrate an archived blob blob_tier_change_time datetime Indicates when the access tier was last changed. blob_tier_inferred bool Indicates whether the access tier was inferred by the service. If false, it indicates that the tier was set explicitly. deleted bool Whether this blob was deleted. deleted_time datetime A datetime object representing the time at which the blob was deleted. remaining_retention_days int The number of days that the blob will be retained before being permanently deleted by the service. creation_time datetime Indicates when the blob was created, in UTC. archive_status str Archive status of blob. encryption_key_sha256 str The SHA-256 hash of the provided encryption key. encryption_scope str A predefined encryption scope used to encrypt the data on the service. An encryption scope can be created using the Management API and referenced here by name. If a default encryption scope has been defined at the container, this value will override it if the container-level scope is configured to allow overrides. Otherwise an error will be raised. request_server_encrypted bool Whether this blob is encrypted. object_replication_source_properties list(ObjectReplicationPolicy) Only present for blobs that have policy ids and rule ids applied to them. New in version 12.4.0. object_replication_destination_policy str Represents the Object Replication Policy Id that created this blob. New in version 12.4.0. last_accessed_on datetime Indicates when the last Read/Write operation was performed on a Blob. New in version 12.6.0. tag_count int Tags count on this blob. New in version 12.4.0. str)
tags dict( Key value pair of tags on this blob. New in version 12.4.0. has_versions_only bool A true value indicates the root blob is deleted New in version 12.10.0. immutability_policy ImmutabilityPolicy Specifies the immutability policy of a blob, blob snapshot or blob version. New in version 12.10.0: This was introduced in API version '2020-10-02'. has_legal_hold bool Specified if a legal hold should be set on the blob. Currently this parameter of upload_blob() API is for BlockBlob only. New in version 12.10.0: This was introduced in API version '2020-10-02'. FeedbackSubmit and view feedback for Skip to main content This browser is no longer supported. Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. Azure Storage Blobs client library for Python - Version 12.13.1
In this articleAzure Blob storage is Microsoft's object storage solution for the cloud. Blob storage is optimized for storing massive amounts of unstructured data, such as text or binary data. Blob storage is ideal for:
Source code | Package (PyPI) | API reference documentation | Product documentation | Samples Getting startedPrerequisites
Install the packageInstall the Azure Storage Blobs client library for Python with pip:
Create a storage accountIf you wish to create a new storage account, you can use the Azure Portal, Azure PowerShell, or Azure CLI:
Create the clientThe Azure Storage Blobs client library for Python allows you to interact with three types of resources: the storage account itself, blob storage containers, and blobs. Interaction with these resources starts with an instance of a client. To create a client object, you will need the storage account's blob service account URL and a credential that allows you to access the storage account:
Looking up the account URLYou can find the storage account's blob service URL using the Azure Portal, Azure PowerShell, or Azure CLI:
Types of credentialsThe
Creating the client from a connection stringDepending on your use case and authorization method, you may prefer to initialize a client instance with a storage connection string instead of providing the
account URL and credential separately. To do this, pass the storage connection string to the client's
The connection string to your storage account can be found in the Azure Portal under the "Access Keys" section or by running the following CLI command:
Key conceptsThe following components make up the Azure Blob Service:
The Azure Storage Blobs client library for Python allows you to interact with each of these components through the use of a dedicated client object. ClientsFour different clients are provided to interact with the various components of the Blob Service:
Async ClientsThis library includes a complete async API supported on Python 3.5+. To use it, you must first install an async transport, such as aiohttp. See azure-core documentation for more information. Async clients and credentials should be closed when they're no longer needed. These objects are async context managers and define async Blob TypesOnce you've initialized a Client, you can choose from the different types of blobs:
ExamplesThe following sections provide several code snippets covering some of the most common Storage Blob tasks, including:
Note that a container must be created before to upload or download a blob. Create a containerCreate a container from where you can upload or download blobs.
Use the async client to upload a blob
Uploading a blobUpload a blob to your container
Use the async client to upload a blob
Downloading a blobDownload a blob from your container
Download a blob asynchronously
Enumerating blobsList the blobs in your container
List the blobs asynchronously
Optional ConfigurationOptional keyword arguments that can be passed in at the client and per-operation level. Retry Policy configurationUse the following keyword arguments when instantiating a client to configure the retry policy:
Encryption configurationUse the following keyword arguments when instantiating a client to configure encryption:
Other client / per-operation configurationOther optional configuration keyword arguments that can be specified on the client or per-operation. Client keyword arguments:
Per-operation keyword arguments:
TroubleshootingGeneralStorage Blob clients raise exceptions defined in Azure Core. This list can be used for reference to catch thrown exceptions. To get the specific error code of the exception, use the LoggingThis library uses the standard logging library for logging. Basic information about HTTP sessions (URLs, headers, etc.) is logged at INFO level. Detailed DEBUG level logging, including request/response bodies and unredacted headers, can be enabled on a client with the
Similarly,
Next stepsMore sample codeGet started with our Blob samples. Several Storage Blobs Python SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Storage Blobs:
Additional documentationFor more extensive documentation on Azure Blob storage, see the Azure Blob storage documentation on docs.microsoft.com. ContributingThis project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments. FeedbackSubmit and view feedback for |