【问题标题】:Enable diagnostics for Azure Storage Account using PowerShell commands使用 PowerShell 命令为 Azure 存储帐户启用诊断
【发布时间】:2018-02-10 04:52:22
【问题描述】:

如何使用 PowerShell 为现有 Azure 存储帐户启用诊断?

谢谢

【问题讨论】:

    标签: azure-storage azure-powershell azure-diagnostics


    【解决方案1】:

    您可以使用 PowerShell 通过使用 cmdlet Set-AzureStorageServiceMetricsProperty 更改当前设置来配置存储帐户中的存储指标。

    示例 1:

    $context = New-AzureStorageContext -StorageAccountName <your storageacount name>
    Set-AzureStorageServiceMetricsProperty -MetricsType Minute -ServiceType Blob -MetricsLevel ServiceAndApi  -RetentionDays 5 -Context $context
    

    我启用了这样的诊断:enable Blob metrics

    如果要启用以下 Blob、Table、Queue 日志,可以使用 cmdlet Set-AzureStorageServiceLoggingProperty 更改当前设置。

    示例 2:

    $context = New-AzureStorageContext -StorageAccountName <your storageacount name>
    Set-AzureStorageServiceLoggingProperty -ServiceType Queue -Context $context  -LoggingOperations read,write,delete -RetentionDays 5  
    

    我启用了这样的队列日志:

    enable Queue logs


    更新:如果您只想在存储帐户中启用诊断日志的存储,请使用以下命令:

    Set-AzureRmDiagnosticSetting -ResourceId [your resource id] -StorageAccountId [your storage account id] -Enabled $true
    

    查看更多关于Set-AzureRmDiagnosticSetting的细节,参考这个:

    docs.microsoft.com/en-us/powershell/module/azurerm.insights/set-azurermdiagnosticsetting?view=azurermps-4.3.1

    【讨论】:

    • 您好韦恩,谢谢您的回复。您提供的命令是 SM 命令行开关。我在 Powershell 中寻找 Azure RM 命令。我发现如果我创建一个新的 Azure 存储帐户,那么默认情况下会启用诊断。但是,如果之前创建了任何现有的存储帐户,则没有可用于更新或启用存储帐户诊断的 powershell 命令
    • 嗨,@Amruta,我确定这些脚本都是 Azure RM powershell cmdlet。您可以尝试一下。有关 Set-AzureStorageServiceMetricsProperty 的更多详细信息请参阅此文档:docs.microsoft.com/en-us/powershell/module/azure.storage/…
    • 在本文档中查看有关 Set-AzureStorageServiceLoggingProperty 的更多详细信息:docs.microsoft.com/en-us/azure/storage/common/…
    • 您好韦恩,谢谢您的回复。这些命令工作得很好。谢谢你。但是这个命令对我不起作用... $StorageAccountResourceId = (Get-AzureRmStorageAccount -Name $StorageAccountName -ResourceGroupName $ResourceGroupName).Id Set-AzureRmDiagnosticSetting -ResourceId $StorageAccountResourceId -Enabled $True
    猜你喜欢
    • 2021-08-21
    • 2023-03-14
    • 1970-01-01
    • 2018-08-27
    • 2014-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多