0
# Blob Operations
1
2
Individual blob operations including upload, download, properties management, and blob-type specific operations. The BlobClient provides comprehensive blob management for all Azure Blob Storage blob types (Block, Page, and Append blobs).
3
4
## Capabilities
5
6
### Client Creation
7
8
Create BlobClient instances with various authentication methods and from different sources including URLs and connection strings.
9
10
```python { .api }
11
class BlobClient:
12
def __init__(self, account_url: str, container_name: str, blob_name: str, snapshot: Optional[Union[str, Dict[str, Any]]] = None, credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, TokenCredential]] = None, **kwargs):
13
"""
14
Create a BlobClient.
15
16
Args:
17
account_url (str): The URL to the storage account
18
container_name (str): Name of the container
19
blob_name (str): Name of the blob
20
snapshot (Optional[Union[str, Dict[str, Any]]]): Snapshot identifier for blob snapshot or snapshot properties dict
21
credential (Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, TokenCredential]]): The credentials for authentication. Can be:
22
- str: Account key or SAS token string
23
- dict: Account name and key mapping
24
- AzureNamedKeyCredential: Named key credential
25
- AzureSasCredential: SAS credential
26
- TokenCredential: Azure AD token credential
27
- None: For anonymous access or SAS URLs
28
"""
29
30
@classmethod
31
def from_blob_url(cls, blob_url: str, credential=None, **kwargs) -> 'BlobClient':
32
"""
33
Create a BlobClient from a blob URL.
34
35
Args:
36
blob_url (str): Complete URL to the blob
37
credential: Optional credential for authentication
38
39
Returns:
40
BlobClient: Configured client instance
41
"""
42
43
@classmethod
44
def from_connection_string(cls, conn_str: str, container_name: str, blob_name: str, **kwargs) -> 'BlobClient':
45
"""
46
Create a BlobClient from a connection string.
47
48
Args:
49
conn_str (str): Azure Storage connection string
50
container_name (str): Name of the container
51
blob_name (str): Name of the blob
52
53
Returns:
54
BlobClient: Configured client instance
55
"""
56
```
57
58
### Basic Blob Operations
59
60
Core blob operations including upload, download, delete, and existence checking.
61
62
```python { .api }
63
def upload_blob(self, data: Union[bytes, str, Iterable[AnyStr], IO[bytes]], blob_type: Union[str, BlobType] = BlobType.BLOCKBLOB, length: Optional[int] = None, metadata: Optional[Dict[str, str]] = None, **kwargs) -> Dict[str, Any]:
64
"""
65
Upload data to create or replace a blob.
66
67
Args:
68
data: Data to upload (bytes, str, or file-like object)
69
blob_type (BlobType): Type of blob to create
70
71
Keyword Args:
72
length (int, optional): Number of bytes to upload
73
metadata (dict, optional): Blob metadata
74
content_type (str, optional): MIME content type
75
content_encoding (str, optional): Content encoding
76
content_language (str, optional): Content language
77
content_disposition (str, optional): Content disposition
78
cache_control (str, optional): Cache control header
79
content_md5 (bytes, optional): MD5 hash of content
80
validate_content (bool): Validate content integrity during upload
81
max_concurrency (int): Maximum concurrent uploads for large blobs
82
overwrite (bool): Whether to overwrite existing blob (default True)
83
standard_blob_tier (StandardBlobTier, optional): Access tier for standard storage
84
premium_page_blob_tier (PremiumPageBlobTier, optional): Tier for premium page blobs
85
tags (dict, optional): Blob index tags as key-value pairs
86
encryption_scope (str, optional): Encryption scope for blob
87
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
88
89
Returns:
90
dict: Upload response with ETag, last modified time, and other properties
91
"""
92
93
def download_blob(self, offset=None, length=None, **kwargs) -> StorageStreamDownloader:
94
"""
95
Download blob content.
96
97
Args:
98
offset (int, optional): Start byte position for partial download
99
length (int, optional): Number of bytes to download
100
101
Keyword Args:
102
version_id (str, optional): Blob version to download
103
validate_content (bool): Validate content integrity during download
104
max_concurrency (int): Maximum concurrent downloads for large blobs
105
encoding (str, optional): Text encoding for string content
106
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
107
108
Returns:
109
StorageStreamDownloader: Streaming downloader with content and properties
110
"""
111
112
def delete_blob(self, delete_snapshots=None, **kwargs) -> None:
113
"""
114
Delete the blob.
115
116
Args:
117
delete_snapshots (str, optional): How to handle snapshots:
118
- 'include': Delete blob and all snapshots
119
- 'only': Delete snapshots but not the blob
120
121
Keyword Args:
122
version_id (str, optional): Specific version to delete
123
lease (BlobLeaseClient or str, optional): Required if blob has active lease
124
if_modified_since (datetime, optional): Delete only if modified since this time
125
if_unmodified_since (datetime, optional): Delete only if not modified since this time
126
etag (str, optional): Delete only if ETag matches
127
match_condition (MatchConditions, optional): ETag matching condition
128
"""
129
130
def exists(self, **kwargs) -> bool:
131
"""
132
Check whether the blob exists.
133
134
Returns:
135
bool: True if blob exists, False otherwise
136
"""
137
138
def undelete_blob(self, **kwargs) -> None:
139
"""
140
Restore a soft-deleted blob.
141
142
Note: Only works if soft delete is enabled on the account
143
"""
144
```
145
146
### Blob Properties and Metadata
147
148
Retrieve and modify blob properties, metadata, HTTP headers, and tags.
149
150
```python { .api }
151
def get_blob_properties(self, **kwargs) -> BlobProperties:
152
"""
153
Get blob properties and metadata.
154
155
Keyword Args:
156
version_id (str, optional): Specific blob version
157
snapshot (str, optional): Blob snapshot identifier
158
lease (BlobLeaseClient or str, optional): Required if blob has active lease
159
if_modified_since (datetime, optional): Return only if modified since this time
160
if_unmodified_since (datetime, optional): Return only if not modified since this time
161
etag (str, optional): Return only if ETag matches
162
match_condition (MatchConditions, optional): ETag matching condition
163
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
164
165
Returns:
166
BlobProperties: Comprehensive blob properties and metadata
167
"""
168
169
def set_blob_metadata(self, metadata=None, **kwargs) -> dict:
170
"""
171
Set blob metadata.
172
173
Args:
174
metadata (dict, optional): Metadata as key-value pairs
175
176
Returns:
177
dict: Response with ETag and last modified time
178
"""
179
180
def set_http_headers(self, content_settings=None, **kwargs) -> dict:
181
"""
182
Set HTTP headers for the blob.
183
184
Args:
185
content_settings (ContentSettings, optional): HTTP header values
186
187
Returns:
188
dict: Response with ETag and last modified time
189
"""
190
191
def set_blob_tags(self, tags=None, **kwargs) -> dict:
192
"""
193
Set blob index tags.
194
195
Args:
196
tags (dict, optional): Tags as key-value pairs
197
198
Returns:
199
dict: Response with ETag and last modified time
200
"""
201
202
def get_blob_tags(self, **kwargs) -> dict:
203
"""
204
Get blob index tags.
205
206
Returns:
207
dict: Blob tags as key-value pairs
208
"""
209
```
210
211
### Blob Snapshots and Versioning
212
213
Create and manage blob snapshots for point-in-time copies.
214
215
```python { .api }
216
def create_snapshot(self, **kwargs) -> dict:
217
"""
218
Create a snapshot of the blob.
219
220
Keyword Args:
221
metadata (dict, optional): Metadata for the snapshot
222
lease (BlobLeaseClient or str, optional): Required if blob has active lease
223
if_modified_since (datetime, optional): Create only if modified since this time
224
if_unmodified_since (datetime, optional): Create only if not modified since this time
225
etag (str, optional): Create only if ETag matches
226
match_condition (MatchConditions, optional): ETag matching condition
227
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
228
229
Returns:
230
dict: Snapshot information including snapshot ID and timestamp
231
"""
232
```
233
234
### Blob Copy Operations
235
236
Copy blobs between locations with progress tracking and cancellation support.
237
238
```python { .api }
239
def start_copy_from_url(self, source_url: str, **kwargs) -> dict:
240
"""
241
Start copying a blob from a source URL.
242
243
Args:
244
source_url (str): URL of the source blob to copy
245
246
Keyword Args:
247
metadata (dict, optional): Metadata for the destination blob
248
incremental_copy (bool): Whether to perform incremental copy (page blobs only)
249
source_lease (BlobLeaseClient or str, optional): Lease for source blob
250
destination_lease (BlobLeaseClient or str, optional): Lease for destination blob
251
source_if_modified_since (datetime, optional): Copy only if source modified since
252
source_if_unmodified_since (datetime, optional): Copy only if source not modified since
253
source_etag (str, optional): Copy only if source ETag matches
254
source_match_condition (MatchConditions, optional): Source ETag matching condition
255
destination_if_modified_since (datetime, optional): Replace only if destination modified since
256
destination_if_unmodified_since (datetime, optional): Replace only if destination not modified since
257
destination_etag (str, optional): Replace only if destination ETag matches
258
destination_match_condition (MatchConditions, optional): Destination ETag matching condition
259
standard_blob_tier (StandardBlobTier, optional): Destination access tier
260
premium_page_blob_tier (PremiumPageBlobTier, optional): Destination premium tier
261
rehydrate_priority (RehydratePriority, optional): Priority for archive rehydration
262
source_authorization (str, optional): Authorization header for source
263
tags (dict, optional): Blob index tags for destination
264
265
Returns:
266
dict: Copy operation details including copy ID and status
267
"""
268
269
def abort_copy(self, copy_id: str, **kwargs) -> None:
270
"""
271
Abort an ongoing copy operation.
272
273
Args:
274
copy_id (str): Copy operation ID to abort
275
"""
276
```
277
278
### Blob Leasing
279
280
Acquire and manage leases on blobs to prevent concurrent modifications.
281
282
```python { .api }
283
def acquire_lease(self, lease_duration=-1, lease_id=None, **kwargs) -> BlobLeaseClient:
284
"""
285
Acquire a lease on the blob.
286
287
Args:
288
lease_duration (int): Lease duration in seconds (-1 for infinite)
289
lease_id (str, optional): Proposed lease identifier
290
291
Returns:
292
BlobLeaseClient: Lease client for managing the lease
293
"""
294
```
295
296
### Storage Tier Management
297
298
Set and modify access tiers for cost optimization and performance requirements.
299
300
```python { .api }
301
def set_standard_blob_tier(self, standard_blob_tier, **kwargs) -> None:
302
"""
303
Set the access tier for a standard storage blob.
304
305
Args:
306
standard_blob_tier (StandardBlobTier): Target access tier
307
308
Keyword Args:
309
rehydrate_priority (RehydratePriority, optional): Priority for archive rehydration
310
lease (BlobLeaseClient or str, optional): Required if blob has active lease
311
version_id (str, optional): Specific version to modify
312
"""
313
314
def set_premium_page_blob_tier(self, premium_page_blob_tier, **kwargs) -> None:
315
"""
316
Set the tier for a premium page blob.
317
318
Args:
319
premium_page_blob_tier (PremiumPageBlobTier): Target premium tier
320
"""
321
```
322
323
### Block Blob Operations
324
325
Block blob specific operations for staging and committing blocks for large uploads.
326
327
```python { .api }
328
def stage_block(self, block_id: str, data, **kwargs) -> None:
329
"""
330
Stage a block for a block blob.
331
332
Args:
333
block_id (str): Base64-encoded block identifier
334
data: Block data to stage
335
336
Keyword Args:
337
length (int, optional): Number of bytes to upload
338
validate_content (bool): Validate block integrity
339
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
340
encryption_scope (str, optional): Encryption scope
341
"""
342
343
def stage_block_from_url(self, block_id: str, source_url: str, **kwargs) -> None:
344
"""
345
Stage a block from a source URL.
346
347
Args:
348
block_id (str): Base64-encoded block identifier
349
source_url (str): URL of source data
350
351
Keyword Args:
352
source_offset (int, optional): Byte offset in source
353
source_length (int, optional): Number of bytes to copy
354
source_content_md5 (bytes, optional): MD5 hash of source range
355
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
356
encryption_scope (str, optional): Encryption scope
357
"""
358
359
def get_block_list(self, **kwargs) -> BlockList:
360
"""
361
Get the list of blocks for a block blob.
362
363
Keyword Args:
364
block_list_type (str): Type of blocks to return:
365
- 'committed': Only committed blocks
366
- 'uncommitted': Only uncommitted blocks
367
- 'all': Both committed and uncommitted blocks
368
snapshot (str, optional): Blob snapshot identifier
369
lease (BlobLeaseClient or str, optional): Required if blob has active lease
370
371
Returns:
372
BlockList: Lists of committed and uncommitted blocks
373
"""
374
375
def commit_block_list(self, block_list, **kwargs) -> dict:
376
"""
377
Commit a list of staged blocks to create or update a block blob.
378
379
Args:
380
block_list (list): List of BlobBlock objects or block IDs
381
382
Keyword Args:
383
content_type (str, optional): MIME content type
384
content_encoding (str, optional): Content encoding
385
content_language (str, optional): Content language
386
content_disposition (str, optional): Content disposition
387
cache_control (str, optional): Cache control header
388
content_md5 (bytes, optional): MD5 hash of content
389
metadata (dict, optional): Blob metadata
390
validate_content (bool): Validate content integrity
391
standard_blob_tier (StandardBlobTier, optional): Access tier
392
tags (dict, optional): Blob index tags
393
immutability_policy (ImmutabilityPolicy, optional): Immutability policy
394
legal_hold (bool, optional): Legal hold status
395
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
396
encryption_scope (str, optional): Encryption scope
397
398
Returns:
399
dict: Commit response with ETag, last modified time, and other properties
400
"""
401
```
402
403
### Page Blob Operations
404
405
Page blob specific operations for random access, sparse data, and virtual machine disks.
406
407
```python { .api }
408
def create_page_blob(self, size: int, **kwargs) -> dict:
409
"""
410
Create a page blob of specified size.
411
412
Args:
413
size (int): Size of the page blob in bytes (must be multiple of 512)
414
415
Keyword Args:
416
content_type (str, optional): MIME content type
417
content_encoding (str, optional): Content encoding
418
content_language (str, optional): Content language
419
content_disposition (str, optional): Content disposition
420
cache_control (str, optional): Cache control header
421
metadata (dict, optional): Blob metadata
422
premium_page_blob_tier (PremiumPageBlobTier, optional): Access tier
423
sequence_number (int, optional): Initial sequence number
424
tags (dict, optional): Blob index tags
425
immutability_policy (ImmutabilityPolicy, optional): Immutability policy
426
legal_hold (bool, optional): Legal hold status
427
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
428
encryption_scope (str, optional): Encryption scope
429
430
Returns:
431
dict: Creation response with ETag, last modified time, and sequence number
432
"""
433
434
def upload_page(self, page, offset: int, **kwargs) -> dict:
435
"""
436
Upload a page to a page blob.
437
438
Args:
439
page: Page data to upload (must be multiple of 512 bytes)
440
offset (int): Byte offset where page starts (must be multiple of 512)
441
442
Keyword Args:
443
length (int, optional): Number of bytes to upload
444
validate_content (bool): Validate page integrity
445
lease (BlobLeaseClient or str, optional): Required if blob has active lease
446
if_sequence_number_less_than_or_equal_to (int, optional): Conditional update
447
if_sequence_number_less_than (int, optional): Conditional update
448
if_sequence_number_equal_to (int, optional): Conditional update
449
if_modified_since (datetime, optional): Upload only if modified since
450
if_unmodified_since (datetime, optional): Upload only if not modified since
451
etag (str, optional): Upload only if ETag matches
452
match_condition (MatchConditions, optional): ETag matching condition
453
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
454
encryption_scope (str, optional): Encryption scope
455
456
Returns:
457
dict: Upload response with ETag, last modified time, and sequence number
458
"""
459
460
def upload_pages_from_url(self, source_url: str, offset: int, source_offset: int, **kwargs) -> dict:
461
"""
462
Upload pages to a page blob from a source URL.
463
464
Args:
465
source_url (str): URL of source data
466
offset (int): Destination byte offset (must be multiple of 512)
467
source_offset (int): Source byte offset (must be multiple of 512)
468
469
Keyword Args:
470
length (int): Number of bytes to copy (must be multiple of 512)
471
source_content_md5 (bytes, optional): MD5 hash of source range
472
content_md5 (bytes, optional): MD5 hash for validation
473
lease (BlobLeaseClient or str, optional): Required if blob has active lease
474
if_sequence_number_less_than_or_equal_to (int, optional): Conditional update
475
if_sequence_number_less_than (int, optional): Conditional update
476
if_sequence_number_equal_to (int, optional): Conditional update
477
if_modified_since (datetime, optional): Upload only if modified since
478
if_unmodified_since (datetime, optional): Upload only if not modified since
479
etag (str, optional): Upload only if ETag matches
480
match_condition (MatchConditions, optional): ETag matching condition
481
source_if_modified_since (datetime, optional): Copy only if source modified since
482
source_if_unmodified_since (datetime, optional): Copy only if source not modified since
483
source_etag (str, optional): Copy only if source ETag matches
484
source_match_condition (MatchConditions, optional): Source ETag matching condition
485
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
486
encryption_scope (str, optional): Encryption scope
487
488
Returns:
489
dict: Upload response with ETag, last modified time, and sequence number
490
"""
491
492
def clear_page(self, offset: int, length: int, **kwargs) -> dict:
493
"""
494
Clear a range of pages in a page blob.
495
496
Args:
497
offset (int): Start byte position to clear (must be multiple of 512)
498
length (int): Number of bytes to clear (must be multiple of 512)
499
500
Returns:
501
dict: Clear response with ETag, last modified time, and sequence number
502
"""
503
504
def get_page_ranges(self, **kwargs) -> PageRanges:
505
"""
506
Get the list of valid page ranges for a page blob.
507
508
Keyword Args:
509
offset (int, optional): Start byte position
510
length (int, optional): Number of bytes to query
511
previous_snapshot (str, optional): Previous snapshot for diff
512
snapshot (str, optional): Blob snapshot identifier
513
lease (BlobLeaseClient or str, optional): Required if blob has active lease
514
if_modified_since (datetime, optional): Return only if modified since
515
if_unmodified_since (datetime, optional): Return only if not modified since
516
etag (str, optional): Return only if ETag matches
517
match_condition (MatchConditions, optional): ETag matching condition
518
519
Returns:
520
PageRanges: List of page ranges with start and end offsets
521
"""
522
523
def resize_blob(self, size: int, **kwargs) -> dict:
524
"""
525
Resize a page blob.
526
527
Args:
528
size (int): New size in bytes (must be multiple of 512)
529
530
Returns:
531
dict: Resize response with ETag, last modified time, and sequence number
532
"""
533
534
def set_sequence_number(self, sequence_number_action, sequence_number=None, **kwargs) -> dict:
535
"""
536
Set the sequence number for a page blob.
537
538
Args:
539
sequence_number_action (SequenceNumberAction): Action to perform
540
sequence_number (int, optional): New sequence number (required for UPDATE and MAX actions)
541
542
Returns:
543
dict: Response with ETag, last modified time, and sequence number
544
"""
545
```
546
547
### Append Blob Operations
548
549
Append blob specific operations for log files and streaming data scenarios.
550
551
```python { .api }
552
def create_append_blob(self, **kwargs) -> dict:
553
"""
554
Create an append blob.
555
556
Keyword Args:
557
content_type (str, optional): MIME content type
558
content_encoding (str, optional): Content encoding
559
content_language (str, optional): Content language
560
content_disposition (str, optional): Content disposition
561
cache_control (str, optional): Cache control header
562
metadata (dict, optional): Blob metadata
563
tags (dict, optional): Blob index tags
564
immutability_policy (ImmutabilityPolicy, optional): Immutability policy
565
legal_hold (bool, optional): Legal hold status
566
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
567
encryption_scope (str, optional): Encryption scope
568
569
Returns:
570
dict: Creation response with ETag and last modified time
571
"""
572
573
def append_block(self, data, **kwargs) -> dict:
574
"""
575
Append data to an append blob.
576
577
Args:
578
data: Data to append
579
580
Keyword Args:
581
length (int, optional): Number of bytes to append
582
validate_content (bool): Validate block integrity
583
max_size (int, optional): Maximum allowed blob size
584
append_position (int, optional): Expected current blob size
585
lease (BlobLeaseClient or str, optional): Required if blob has active lease
586
if_modified_since (datetime, optional): Append only if modified since
587
if_unmodified_since (datetime, optional): Append only if not modified since
588
etag (str, optional): Append only if ETag matches
589
match_condition (MatchConditions, optional): ETag matching condition
590
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
591
encryption_scope (str, optional): Encryption scope
592
593
Returns:
594
dict: Append response with ETag, last modified time, and append offset
595
"""
596
597
def append_block_from_url(self, copy_source_url: str, **kwargs) -> dict:
598
"""
599
Append data to an append blob from a source URL.
600
601
Args:
602
copy_source_url (str): URL of source data
603
604
Keyword Args:
605
source_offset (int, optional): Byte offset in source
606
source_length (int, optional): Number of bytes to copy
607
source_content_md5 (bytes, optional): MD5 hash of source range
608
max_size (int, optional): Maximum allowed blob size
609
append_position (int, optional): Expected current blob size
610
lease (BlobLeaseClient or str, optional): Required if blob has active lease
611
if_modified_since (datetime, optional): Append only if modified since
612
if_unmodified_since (datetime, optional): Append only if not modified since
613
etag (str, optional): Append only if ETag matches
614
match_condition (MatchConditions, optional): ETag matching condition
615
source_if_modified_since (datetime, optional): Copy only if source modified since
616
source_if_unmodified_since (datetime, optional): Copy only if source not modified since
617
source_etag (str, optional): Copy only if source ETag matches
618
source_match_condition (MatchConditions, optional): Source ETag matching condition
619
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
620
encryption_scope (str, optional): Encryption scope
621
622
Returns:
623
dict: Append response with ETag, last modified time, and append offset
624
"""
625
626
def seal_append_blob(self, **kwargs) -> dict:
627
"""
628
Seal an append blob to make it read-only.
629
630
Returns:
631
dict: Seal response with ETag and last modified time
632
"""
633
```
634
635
### Blob Query Operations
636
637
Execute SQL-like queries on blob content for structured data processing.
638
639
```python { .api }
640
def query_blob(self, query_expression: str, **kwargs) -> BlobQueryReader:
641
"""
642
Execute a SQL query on blob content.
643
644
Args:
645
query_expression (str): SQL query to execute on blob data
646
647
Keyword Args:
648
blob_format (QuickQueryDialect): Input data format configuration
649
output_format (QuickQueryDialect): Output data format configuration
650
on_error (callable, optional): Error handler function
651
blob_query_error_callback (callable, optional): Query error callback
652
snapshot (str, optional): Blob snapshot identifier
653
lease (BlobLeaseClient or str, optional): Required if blob has active lease
654
if_modified_since (datetime, optional): Query only if modified since
655
if_unmodified_since (datetime, optional): Query only if not modified since
656
etag (str, optional): Query only if ETag matches
657
match_condition (MatchConditions, optional): ETag matching condition
658
cpk (CustomerProvidedEncryptionKey, optional): Customer-provided encryption key
659
660
Returns:
661
BlobQueryReader: Query results with streaming capabilities
662
"""
663
```
664
665
### Immutability and Legal Hold
666
667
Manage data immutability policies and legal holds for compliance scenarios.
668
669
```python { .api }
670
def set_immutability_policy(self, **kwargs) -> dict:
671
"""
672
Set an immutability policy on the blob.
673
674
Keyword Args:
675
immutability_policy (ImmutabilityPolicy): Policy configuration
676
if_unmodified_since (datetime, optional): Set only if not modified since
677
678
Returns:
679
dict: Response with immutability policy details
680
"""
681
682
def delete_immutability_policy(self, **kwargs) -> dict:
683
"""
684
Delete the immutability policy from the blob.
685
686
Returns:
687
dict: Response confirming policy deletion
688
"""
689
690
def set_legal_hold(self, legal_hold: bool, **kwargs) -> dict:
691
"""
692
Set or clear legal hold on the blob.
693
694
Args:
695
legal_hold (bool): Whether to set (True) or clear (False) legal hold
696
697
Returns:
698
dict: Response with legal hold status
699
"""
700
```
701
702
### Account Information
703
704
Retrieve storage account information through the blob client.
705
706
```python { .api }
707
def get_account_information(self, **kwargs) -> dict:
708
"""
709
Get information about the storage account.
710
711
Returns:
712
dict: Account information including account kind and SKU
713
"""
714
```
715
716
## Supporting Data Types
717
718
```python { .api }
719
class StorageStreamDownloader:
720
"""Streaming downloader for blob content."""
721
def readall(self) -> bytes: ...
722
def readinto(self, stream) -> int: ...
723
def download_to_stream(self, stream) -> None: ...
724
def chunks(self) -> Iterator[bytes]: ...
725
def content_as_bytes(self) -> bytes: ...
726
def content_as_text(self, encoding: str = 'utf-8') -> str: ...
727
728
class BlobProperties:
729
"""Comprehensive blob properties."""
730
name: str
731
container: str
732
snapshot: str
733
blob_type: BlobType
734
last_modified: datetime
735
etag: str
736
size: int
737
content_type: str
738
content_encoding: str
739
content_language: str
740
content_disposition: str
741
cache_control: str
742
content_md5: bytes
743
metadata: dict
744
lease: LeaseProperties
745
copy: CopyProperties
746
creation_time: datetime
747
archive_status: str
748
rehydrate_priority: str
749
encryption_key_sha256: str
750
encryption_scope: str
751
request_server_encrypted: bool
752
object_replication_source_properties: list
753
object_replication_destination_policy: str
754
tag_count: int
755
tags: dict
756
immutability_policy: ImmutabilityPolicy
757
has_legal_hold: bool
758
has_versions_only: bool
759
760
class ContentSettings:
761
"""HTTP headers for blob content."""
762
content_type: str
763
content_encoding: str
764
content_language: str
765
content_disposition: str
766
cache_control: str
767
content_md5: bytes
768
769
class BlobBlock:
770
"""Block information for block blobs."""
771
block_id: str
772
state: BlockState
773
774
class BlockList:
775
"""Block list for block blobs."""
776
committed_blocks: list[BlobBlock]
777
uncommitted_blocks: list[BlobBlock]
778
779
class PageRange:
780
"""Page range for page blobs."""
781
start: int
782
end: int
783
784
class PageRanges:
785
"""Page ranges collection."""
786
page_ranges: list[PageRange]
787
clear_ranges: list[PageRange]
788
789
class CopyProperties:
790
"""Blob copy operation properties."""
791
id: str
792
source: str
793
status: str
794
progress: str
795
completion_time: datetime
796
status_description: str
797
incremental_copy: bool
798
destination_snapshot: str
799
800
class ImmutabilityPolicy:
801
"""Blob immutability policy."""
802
expiry_time: datetime
803
policy_mode: BlobImmutabilityPolicyMode
804
805
class CustomerProvidedEncryptionKey:
806
"""Customer-managed encryption key."""
807
key_value: str
808
key_hash: str
809
algorithm: str
810
811
class BlobQueryReader:
812
"""SQL query results reader."""
813
def readall(self) -> bytes: ...
814
def readinto(self, stream) -> int: ...
815
```