Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eNeRGy164/6f055a0614bcb89586b3fbdad8d99c32 to your computer and use it in GitHub Desktop.
Save eNeRGy164/6f055a0614bcb89586b3fbdad8d99c32 to your computer and use it in GitHub Desktop.
param(
[string]$resourceGroup,
[string]$storageAccountName
[string]$webAppName
)
Import-Module AzureRM.Storage
$sa = Get-AzureRmStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccountName
Write-Host
Write-Host "Retrieved storage account"
Write-Verbose ($sa | Out-String)
New-AzureStorageContainer -Context $sa.Context -Name "webapp-logs" -ErrorAction Ignore | Out-Null
$sasToken = New-AzureStorageContainerSASToken -Context $sa.Context -Name webapp-logs -FullUri -Permission rwdl -ExpiryTime (Get-Date).Date.AddYears(200) -StartTime (Get-Date).Date
Write-Host
Write-Host "Generated SAS token"
Write-Verbose ($sasToken | Out-String)
$webApp = Get-AzureRmWebApp -ResourceGroupName $resourceGroup -Name $webAppName
Write-Host
Write-Host "Retrieved web app"
Write-Verbose ($webApp | Out-String)
$appSettings = [ordered]@{}
$webapp.SiteConfig.AppSettings | % { $appSettings[$_.Name] = $_.Value }
Write-Host
if ($appSettings.DIAGNOSTICS_AZUREBLOBCONTAINERSASURL -eq $null) {
$appSettings.DIAGNOSTICS_AZUREBLOBCONTAINERSASURL = [string]$sasToken
Write-Host "Updating web app"
Set-AzureRmWebApp -ResourceGroupName $resourceGroup -Name $webAppName -AppSettings $appSettings | Out-Null
} else {
Write-Host "Skipped updating web app, already contains the Diagnostics Azure Blob Container SAS URL"
}
Write-Host "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment