Created
March 16, 2016 14:18
-
-
Save markusjohnsson/e9d09d78ca9ee7c9190e to your computer and use it in GitHub Desktop.
Setting a property (CacheControl) to all blobs in a Azure blob storage container
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
using Microsoft.WindowsAzure.Storage; | |
using Microsoft.WindowsAzure.Storage.Blob; | |
using System; | |
using System.Linq; | |
namespace SetNoCache | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var blobConectionString = "<connectionstring>"; | |
CloudStorageAccount backupStorageAccount = CloudStorageAccount.Parse(blobConectionString); | |
var backupBlobClient = backupStorageAccount.CreateCloudBlobClient(); | |
var backupContainer = backupBlobClient.GetContainerReference("<container>"); | |
foreach (var blob in backupContainer.ListBlobs(useFlatBlobListing: true).OfType<CloudBlockBlob>()) | |
{ | |
blob.Properties.CacheControl = "no-cache"; | |
blob.SetProperties(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment