本文介绍了有没有办法使用 PowerShell 或 ARM 模板为 azure 应用服务启用应用程序日志记录到 blob?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们为 Azure 门户中的 azure 应用服务启用应用程序日志记录到 blob.有没有办法使用 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 命令 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
对于 ARM 模板,您可以参考这个 .
For ARM template, you could refer to this demo.
这篇关于有没有办法使用 PowerShell 或 ARM 模板为 azure 应用服务启用应用程序日志记录到 blob?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!