Adding Azure blob content properties with PowerShell
If you, like me, like Azure and PowerShell you might wonder how to add properties to a blob when uploading. Its simple, the command for upload has a Properties parameter of the type HashTable.
A HashTable is a collection of key value pairs, and for out properties the key is what we want to set and the value what we want to set it to. We do so passing in strings, wrapped in code hugs (or curly braces as others call them). Okay, I am the only one calling them code hugs.
Example:
$properties = @{“CacheControl” = “public, max-age=86400”}
So for an upload it would look like something like this (back ticks allows multi line commands- I’ve used it here to make the script more readable, but they are not necessary in this command so remove them and use a one-liner instead if you decide to copy and paste):
$context = New-AzureStorageContext -StorageAccountName $accName -StorageAccountKey $key
$properties = @{“CacheControl” = “public, max-age=86400”}
Set-AzureStorageBlobContent ** **-Blob $blobNameWithExtension
-Container “Name of container” ** **-File $file
-Properties $properties ** **-Context $context
-Force
Image:
Comments
Last modified on 2014-06-10