Is there a way to enable application logging to blob for azure app service using PowerShell or ARM template?

江枫思渺然 提交于 2019-12-11 04:11:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!