Created
December 18, 2017 09:37
-
-
Save bcnzer/1658814d3456d547e09d1194feccbddb to your computer and use it in GitHub Desktop.
Script I use to fix the content types.
This file contains hidden or 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
# 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