Created
June 9, 2020 15:39
-
-
Save BelRarr/90e09fb0983b84f4f9efb048008db81c to your computer and use it in GitHub Desktop.
Setting the CacheControl property on an Azure Blob Storage element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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