我想确保我的工作者角色始终配置了正确的诊断程序,但我遇到了一些问题,并且发现这方面的文档非常不清楚 .

我在工作者角色上设置了诊断程序并按预期运行;例如,所有WAD表都被填充 .

这已经工作了好几个月,我们已经部署(通过从暂存到 生产环境 的交换VIP)新版本的工作者角色,并且诊断工作继续按预期运行 .

然而,最近,我们部署了新版本的Worker Role(再次通过Swap VIP),并且已经删除了诊断程序 . 使用

Get-AzureServiceDiagnosticsExtension -ServiceName "blah" -Slot "Production"

cmdlet我可以看到,确实在Worker Role上没有诊断配置 .

显然,我错过了使用如何配置工作者角色的方法

Set-AzureServiceDiagnosticsExtension

The documentation is very unclear about what the -Role and -Slot parameters do

(empahsis mine)

-Role <String []>用于指定诊断配置的可选角色数组 . 如果未指定,则将诊断配置应用为所有角色的默认配置 .

这是否意味着所有部署立即获得配置,无论他们的角色还是插槽?或者这是否意味着我为之后制作的任何部署设置"default"?如果我后来使用-Slot参数运行此命令,这会影响"default"吗?为什么`Get-AzureServiceDiagnosticExtension not 有一个-Role参数?

-Slot <String>指定要修改的部署的环境 . 支持的值为“ 生产环境 ”或“暂存” .

但是如果我不提供-Slot呢?这是否意味着所有插槽 immediately 都获得配置? -Sole是如何使用-Role的,因为在这里没有提到"default",如-Role文档?

额外的混淆来自 Remove-AzureServiceDiagnosticsExtension also has -Slot and -Role ,但documentation并不清楚它如何与 Set- cmdlet文档中描述的"default"配置相符 . 不使用-Role或-Slot删除所有内容,还是只删除 Set- 没有-Role或-Slot?

我想要做的是确保我只需要设置诊断 Once . 即在我第一次创建工作者角色时,我设置了诊断程序,而不必再次触摸它 .

但是,我还有一个额外的复杂功能,我希望 not 为Staging记录诊断,只记录 生产环境 .

我一直在玩cmdlet和测试,但我没有信心,因为

  • 在交换新版本时删除了诊断信息的事实,即使它们在以前的交换中没有问题

  • 文件很不清楚 .

UPDATE

为了更好地理解这一点,我假设通过 生产环境 槽上的诊断*,我将得到我需要的设置 .

我这样做了:

Set-AzureServiceDiagnosticsExtension -ServiceName "MyCloudService" `
  -Slot Production -DiagnosticsConfigurationPath "<path to file>" `
  -StorageContext "<context>" -CertificateThumbprint "CERTHUMBPRINT"

但你从 Get-Remove- 得到的不是你所期望的:

  • 获取, no slot

Get-AzureServiceDiagnosticsExtension -ServiceName "MyCloudService"

返回一个ID为对象的对象( NOT EXPECTED

Default-PaaSDiagnostics-Production-Ext-0

  • 获取, Production 插槽

Get-AzureServiceDiagnosticsExtension -ServiceName "MyCloudService" -Slot Production

返回一个具有ID(预期)的对象

Default-PaaSDiagnostics-Production-Ext-0

  • 获取, Staging 插槽

Get-AzureServiceDiagnosticsExtension -ServiceName "MyCloudService" -Slot Staging

不返回任何对象(预期)

  • 删除,没有角色或插槽

Remove-AzureServiceDiagnosticsExtension -ServiceName "MyCloudService"

返回任何要删除的内容(预期)

警告:在给定角色上未启用现有Microsoft.Azure.Diagnostics.PaaSDiagnostics扩展 .

  • 删除,没有角色但是 Staging Slot

Remove-AzureServiceDiagnosticsExtension -ServiceName "MyCloudService" -Slot Staging

返回任何要删除的内容(预期)

警告:在给定角色上未启用现有Microsoft.Azure.Diagnostics.PaaSDiagnostics扩展 .

  • 删除,使用角色"MyRole"和 Staging 插槽

Remove-AzureServiceDiagnosticsExtension -ServiceName "MyCloudService" -Role "MyRole" -Slot Staging

返回任何要删除的内容(预期)

警告:在给定角色上未启用现有Microsoft.Azure.Diagnostics.PaaSDiagnostics扩展 .

  • 删除,没有角色但 Production 插槽

Remove-AzureServiceDiagnosticsExtension -ServiceName "MyCloudService" -Slot Production

不返回任何要删除的内容( NOT EXPECTED

警告:在给定角色上未启用现有Microsoft.Azure.Diagnostics.PaaSDiagnostics扩展 .

  • 删除,使用角色"MyRole"和 Production 插槽

Remove-AzureServiceDiagnosticsExtension -ServiceName "MyCloudService" -Role "MyRole" -Slot Staging

返回成功删除( NOT EXPECTED

警告:从Cloud Service MyCloudService中删除MyRole的PaaSDiagnostics配置 .

我不明白为什么带有 no SlotGet- 将返回诊断程序,但 Remove-no Role or Slot 表示没有任何内容 .

同样,为什么 Remove- 不起作用 without the Role 而不是 with the Role