1

My team has a .NET (4.7) web application running in Azure. Right now there are three directories being creations on the web in the D drive - cache, temp and root. Log files are dumped here. My concern is that these log files will take up space and crash the app.

Is it possible to store these apps in blob container instead of on the web application? I created a storage account with three containers (cache, temp, root), used Storage Explorer to create shared access signatures (SAS's) on each container, and then pasted the URL generated for the SAS in the app settings for the web app. I restarted the app no files are being dumped in the container.

Is there something I'm missing to get this working? I'm not a developer so I'm not sure if something would need to be set in the code for this to work. I noticed in the web.config a D:\home...... location was specified so I assumed adding the container location would work but I guess not. Any thoughts or suggestions would be greatly appreciated.

jrd1989
  • 628
  • 10
  • 35

1 Answers1

0

Try doing it via PowerShell, as explained here:

The configuration is done in 6 steps.

  1. We get the Storage Account where we want to store the Application Logs.

$sa = Get-AzureRmStorageAccount -ResourceGroupName "loremipsumresourcegroup" -Name "loremipsumstore"

  1. We make sure there is a container to store the logs. Because we can run the script multiple times, we ignore the error if the container already exists.

New-AzureStorageContainer -Context $sa.Context -Name "webapp-logs" -ErrorAction Ignore

  1. Next, we generate the SAS token for the container. We use the same settings Microsoft uses when creating the link using the Azure Portal.

$sasToken = New-AzureStorageContainerSASToken -Context $sa.Context -Name "webapp-logs" -FullUri -Permission rwdl -StartTime (Get-Date).Date -ExpiryTime (Get-Date).Date.AddYears(200)

  1. We want to update the AppSettings as the configuration is stored there. But when you update the AppSettings, any setting not present in the update will be removed. Therefore, we first want to get all the existing AppSettings.

$webApp = Get-AzureRmWebApp -ResourceGroupName "loremipsumresourcegroup" -Name "LoremIpsumWebApp"

  1. Strangely the Set-AzureRmWebApp command does not accept the SiteConfig.AppSettings we got from the Get-AzureRmWebApp command. We need to create a Hash Table for this. To make sure the Application Settings keep the same order, we define the Hash Table as Ordered.

$appSettings = [ordered]@{} $webapp.SiteConfig.AppSettings | % { $appSettings[$.Name] = $.Value } $appSettings.DIAGNOSTICS_AZUREBLOBCONTAINERSASURL = [string]$sasToken

  1. Now we can update the App Service using the Set-AzureRmWebApp command.

Set-AzureRmWebApp -ResourceGroupName "loremipsumresourcegroup" -Name "LoremIpsumWebApp" -AppSettings $appSettings

All the credits to Michaƫl Hompus

Gabriel Talavera
  • 1,367
  • 1
  • 11
  • 18