【问题标题】:Is there a way to enable application logging to blob for azure app service using PowerShell or ARM template?有没有办法使用 PowerShell 或 ARM 模板为 Azure 应用服务启用应用程序日志记录?
【发布时间】:2018-01-18 20:28:34
【问题描述】:

我们为 Azure 门户中的 Azure 应用服务启用应用程序日志记录。有没有办法使用 PowerShell 或 ARM 模板来做到这一点。如果是,请提供示例代码。

【问题讨论】:

    标签: azure azure-web-app-service arm-template


    【解决方案1】:

    有没有办法使用 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

    【讨论】:

    • 感谢汤姆的回复。抱歉,由于时间关系,我无法实现。
    猜你喜欢
    • 1970-01-01
    • 2017-09-12
    • 2020-11-10
    • 2017-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-22
    相关资源
    最近更新 更多