The documentation for the batch_set_standard_blob_tier function part of BlockBlobService in azure python SDK is not clear. What exactly should be passed in the parameter? An example would be appreciated.
Asked
Active
Viewed 1,215 times
2 Answers
0
What exactly should be passed in the parameter?
Input to this method is a list of BatchSetBlobTierSubRequest
object.

Gaurav Mantri
- 128,066
- 12
- 206
- 241
0
I know it's not a direct answer to your question, but in the v12 actually in preview, I believe the usage is far more obvious:
Example of code:
tiers = [StandardBlobTier.Archive, StandardBlobTier.Cool, StandardBlobTier.Hot]
for tier in tiers:
blob = container.get_blob_client('blob1')
data = b'hello world'
blob.upload_blob(data)
container.get_blob_client('blob2').upload_blob(data)
container.get_blob_client('blob3').upload_blob(data)
blob_ref = blob.get_blob_properties()
assert blob_ref.blob_tier is not None
assert blob_ref.blob_tier_inferred
assert blob_ref.blob_tier_change_time is None
parts = container.set_standard_blob_tier_blobs(
tier,
'blob1',
'blob2',
'blob3',
)
parts = list(parts)
assert len(parts) == 3
assert parts[0].status_code in [200, 202]
assert parts[1].status_code in [200, 202]
assert parts[2].status_code in [200, 202]
blob_ref2 = blob.get_blob_properties()
assert tier == blob_ref2.blob_tier
assert not blob_ref2.blob_tier_inferred
assert blob_ref2.blob_tier_change_time is not None
The new Storage SDK is planned to be GA stable release in November 2019, so it's really close and might worth a try.
Note that you can always open questions about code and documentation, whatever versions of SDK, in Github: https://github.com/Azure/azure-sdk-for-python/issues
Even if you can't use the preview right now, feedback on the new API would be appreciated :)
(Disclosure: I work at MS in the SDK team)

Laurent Mazuel
- 3,422
- 13
- 27