Created
May 29, 2017 11:53
-
-
Save eNeRGy164/6f055a0614bcb89586b3fbdad8d99c32 to your computer and use it in GitHub Desktop.
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
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