44require_relative "blob_list"
55require_relative "blob"
66require_relative "container"
7+ require_relative "tags"
78require_relative "http"
89require_relative "shared_key_signer"
910require_relative "entra_id_signer"
@@ -28,7 +29,7 @@ def initialize(account_name:, access_key: nil, principal_id: nil, container:, **
2829 )
2930 end
3031 @signer = using_managed_identities ?
31- AzureBlob ::EntraIdSigner . new ( account_name :, host :, principal_id : ) :
32+ AzureBlob ::EntraIdSigner . new ( account_name :, host :, principal_id :) :
3233 AzureBlob ::SharedKeySigner . new ( account_name :, access_key :)
3334 end
3435
@@ -157,6 +158,20 @@ def get_blob_properties(key, options = {})
157158 Blob . new ( response )
158159 end
159160
161+ # Returns the tags associated with a blob
162+ #
163+ # Calls to the {Get Blob Tags}[https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob-tags] endpoint.
164+ #
165+ # Takes a key (path) of the blob.
166+ #
167+ # Returns a hash of the blob's tags.
168+ def get_blob_tags ( key )
169+ uri = generate_uri ( "#{ container } /#{ key } ?comp=tags" )
170+ response = Http . new ( uri , signer :) . get
171+
172+ Tags . from_response ( response ) . to_h
173+ end
174+
160175 # Returns a Container object.
161176 #
162177 # Calls to {Get Container Properties}[https://learn.microsoft.com/en-us/rest/api/storageservices/get-container-properties]
@@ -230,7 +245,7 @@ def create_append_blob(key, options = {})
230245 "x-ms-blob-content-disposition" : options [ :content_disposition ] ,
231246 }
232247
233- Http . new ( uri , headers , metadata : options [ :metadata ] , signer : ) . put ( nil )
248+ Http . new ( uri , headers , signer : , ** options . slice ( :metadata , :tags ) ) . put ( nil )
234249 end
235250
236251 # Append a block to an Append Blob
@@ -305,7 +320,7 @@ def commit_blob_blocks(key, block_ids, options = {})
305320 "x-ms-blob-content-disposition" : options [ :content_disposition ] ,
306321 }
307322
308- Http . new ( uri , headers , metadata : options [ :metadata ] , signer : ) . put ( content )
323+ Http . new ( uri , headers , signer : , ** options . slice ( :metadata , :tags ) ) . put ( content )
309324 end
310325
311326 private
@@ -337,7 +352,7 @@ def put_blob_single(key, content, options = {})
337352 "x-ms-blob-content-disposition" : options [ :content_disposition ] ,
338353 }
339354
340- Http . new ( uri , headers , metadata : options [ :metadata ] , signer : ) . put ( content . read )
355+ Http . new ( uri , headers , signer : , ** options . slice ( :metadata , :tags ) ) . put ( content . read )
341356 end
342357
343358 def host
0 commit comments