【发布时间】:2018-01-18 20:28:34
【问题描述】:
我们为 Azure 门户中的 Azure 应用服务启用应用程序日志记录。有没有办法使用 PowerShell 或 ARM 模板来做到这一点。如果是,请提供示例代码。
【问题讨论】:
标签: azure azure-web-app-service arm-template
我们为 Azure 门户中的 Azure 应用服务启用应用程序日志记录。有没有办法使用 PowerShell 或 ARM 模板来做到这一点。如果是,请提供示例代码。
【问题讨论】:
标签: azure azure-web-app-service arm-template
有没有办法使用 PowerShell 或 ARM 模板来做到这一点。如果是,请提供示例代码。
我们使用 powershell 命令Set-AzureRmResource -Properties 来执行此操作。
我们也可以从https://resources.azure.com/ 获取命令。它在我这边工作正常。
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模板可以参考demo。
【讨论】: