Skip to content

Instantly share code, notes, and snippets.

@bcnzer
Created December 18, 2017 09:37
Show Gist options
  • Save bcnzer/1658814d3456d547e09d1194feccbddb to your computer and use it in GitHub Desktop.
Save bcnzer/1658814d3456d547e09d1194feccbddb to your computer and use it in GitHub Desktop.
Script I use to fix the content types.
# Note that variables. You can just replace them with text in quotes. For the WolfTrackerBlobKey I would suggest pulling
# that data from Azure Key Vault
$Context = New-AzureStorageContext -StorageAccountName $(BlobServiceName) -StorageAccountKey $(WolfTrackerBlobKey)
$Blobs = Get-AzureStorageBlob -Context $Context -Container $(WolfTrackerBlobContainer)
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