Skip to content

Instantly share code, notes, and snippets.

@ssaraswati
Created March 21, 2018 03:18
Show Gist options
  • Save ssaraswati/27648f740351ee96505807a173b74a89 to your computer and use it in GitHub Desktop.
Save ssaraswati/27648f740351ee96505807a173b74a89 to your computer and use it in GitHub Desktop.
Param(
[string]$storageaccountsecret
)
$StorageAccountName = "$($env:storageaccountname)"
$Context = New-AzureStorageContext -StorageAccountName $env:storageaccountname -StorageAccountKey $storageaccountsecret
$Blobs = Get-AzureStorageBlob -Context $Context -Container $env:webcontainer
foreach ($Blob in $Blobs)
{
$Extn = [IO.Path]::GetExtension($Blob.Name)
$ContentType = ""
switch ($Extn) {
".json" { $ContentType = "application/json" }
".js" { $ContentType = "application/javascript" }
".svg" { $ContentType = "image/svg+xml" }
Default { $ContentType = "" }
}
if ($ContentType -ne "") {
$CloudBlockBlob = [Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob] $Blob.ICloudBlob
$CloudBlockBlob.Properties.ContentType = $ContentType
$CloudBlockBlob.SetProperties()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment