Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BelRarr/90e09fb0983b84f4f9efb048008db81c to your computer and use it in GitHub Desktop.
Save BelRarr/90e09fb0983b84f4f9efb048008db81c to your computer and use it in GitHub Desktop.
Setting the CacheControl property on an Azure Blob Storage element
# Connect to Azure and position on the desired subscription
Connect-AzAccount
Get-AzSubscription -SubscriptionName "Microsoft Azure Sponsorship" | Set-AzContext
# Create a storage context
$context = New-AzStorageContext -StorageAccountName "staticwebsitestorage2" -StorageAccountKey "*****"
# Get a reference to the blob
$blob = Get-AzStorageBlob -Context $context -Container "images" -Blob "lighthouse.jfif"
# Set the CacheControl property to expire in 2 minutes (120 seconds) for the sake of the demo
$blob.ICloudBlob.Properties.CacheControl = "max-age=120"
# Send the update to the cloud
$blob.ICloudBlob.SetProperties()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment