问题
We enable application logging to blob for azure app service in the Azure portal. Is there a way to do this using PowerShell or ARM template. If yes, please provide sample code.
回答1:
Is there a way to do this using PowerShell or ARM template. If yes, please provide sample code.
We use the powershell command Set-AzureRmResource -Properties
to do that.
We also could get the command from https://resources.azure.com/
. It works correctly on my side.
Login-AzureRmAccount
# get the log setting
$logSetting = Get-AzureRmResource -ResourceGroupName "ResourceGroupName" -ResourceType Microsoft.Web/sites/config -ResourceName "webAppname/logs" -ApiVersion 2016-08-01
$logSetting .Properties.applicationLogs.azureBlobStorage.level = "Error"
$logSetting .Properties.applicationLogs.azureBlobStorage.sasUrl = "storage account sas token url"
$logSetting .Properties.applicationLogs.azureBlobStorage.retentionInDays = 3
# update the log setting
$result = Set-AzureRmResource -Properties $logSetting.Properties -ResourceGroupName "ResourceGroupName" -ResourceType Microsoft.Web/sites/config -ResourceName "webAppname/logs" -ApiVersion 2016-08-01 -Force
For ARM template, you could refer to this demo.
来源:https://stackoverflow.com/questions/48329776/is-there-a-way-to-enable-application-logging-to-blob-for-azure-app-service-using