Azure PowerShell Cmdlet 和设置服务诊断 (Set-AzureServiceDiagnosticsExtension)

标签 azure azure-diagnostics azure-powershell azure-deployment

自从我们更新到 Azure SKD 2.5 以来,我们无法再在角色启动时更新诊断配置。我们现在改用 Microsoft Azure PowerShell Cmdlet 来更新我们的 Web 和辅助角色诊断配置。

在开发配置脚本时,我们注意到,如果不先调用 Remove-AzureServiceDiagnosticsExtension,则调用 Set-AzureServiceDiagnosticsExtension 将会失败,并出现以下错误:

VERBOSE: Setting default PaaSDiagnostics configuration for all roles.
VERBOSE: 10:01:19 AM - Begin Operation: Set-AzureServiceDiagnosticsExtension
Set-AzureServiceDiagnosticsExtension : BadRequest: Cannot add extension 'Default-PaaSDiagnostics-Production-Ext-0'
with same name space 'Microsoft.Azure.Diagnostics' and type 'PaaSDiagnostics' more than once.
At C:\Github\cloud-build\lib\UpdateDiagnosticsBuildStep.ps1:109 char:7
+       Set-AzureServiceDiagnosticsExtension -StorageContext $storageContext -Diag ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzureServiceDiagnosticsExtension], CloudException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureServiceDiagnosticsE
   xtensionCommand

理想情况下,我们可以只调用 set 来更新现有配置。有没有更好的方法来做到这一点,不需要我们调用删除和设置?

我们还注意到,通过 powershell 更新诊断配置与角色启动时更新诊断配置相比,我们的整体部署时间大约增加了一倍。我认为这种增加主要归因于配置更新时角色的重新启动。有办法避免这种情况吗?

谢谢!

最佳答案

确保在调用Set-AzureServiceDiagnosticsExtension时添加-Role参数。

正如Saurabh Bhatia在评论@Windows Azure Diagnostics – Upgrading from Azure SDK 2.4 to Azure SDK 2.5中指出的那样,

For the Powershell Script please make sure to explicitly pass in a -Role when you set the extension. If an extension already exists and if you don't pass in the role explicitly then you may see the error mentioned.

Similarly when you remove the extension make sure to explicitly pass in the -role from which you want to remove the extension.

If no diagnostic extension is present on any of the roles then you can call the set extension ps without the Role to set the extension on all roles.

关于Azure PowerShell Cmdlet 和设置服务诊断 (Set-AzureServiceDiagnosticsExtension),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27605321/

相关文章:

未找到 Azure Blob 存储

azure - 自动/计划每日 USQL 脚本执行

azure - Snowpipe 云消息传递机制在 Azure 上到底如何工作?

azure - 下载 azure 诊断日志?

azure - Windows Azure 诊断错误 :

azure - 为什么我的 IIS 日志没有被复制到我的 Azure Web 角色?

azure - 30 天后自动终止 Azure VM

azure - 如何在 Azure 中自动部署机器人 channel 注册?

asp.net - 如何在azure虚拟机中部署asp.net webapp

powershell - 使用 SAS token 上传 Blob 内容