有没有一种方法可以使用PowerShell或ARM模板启用将应用程序日志记录到blob中的Azure应用服务? [英] Is there a way to enable application logging to blob for azure app service using PowerShell or ARM template?
问题描述
我们在Azure门户中启用了将应用程序日志记录到Blob以获得Azure应用服务的功能.有没有一种使用PowerShell或ARM模板执行此操作的方法.如果是,请提供示例代码.
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.
推荐答案
是否有一种使用PowerShell或ARM模板执行此操作的方法.如果是,请提供示例代码.
Is there a way to do this using PowerShell or ARM template. If yes, please provide sample code.
我们使用powershell命令Set-AzureRmResource -Properties
来做到这一点.
We use the powershell command Set-AzureRmResource -Properties
to do that.
我们也可以从https://resources.azure.com/
获取命令.它在我这边正常工作.
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.
这篇关于有没有一种方法可以使用PowerShell或ARM模板启用将应用程序日志记录到blob中的Azure应用服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!