无法为Azure上的Cloud Service启用AzureServiceDiagnosticsExtension

时间:2016-05-27 06:19:32

标签: azure azure-cloud-services diagnostics azure-diagnostics

我无法通过powershell命令为我的云服务设置诊断扩展。我收到了以下错误:

New-AzureServiceDiagnosticsExtensionConfig : The element StorageAccount 
doesn't match the storage account name provided in the cmdlet arguments. It is 
recommended to not use the element StorageAccount as it is automatically set 
by the cmdlet.

用于启用Cloud Service诊断的Powershell命令

$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
Set-AzureServiceDiagnosticsExtension -StorageContext $storageContext -DiagnosticsConfigurationPath $diagnosticFileLocation -ServiceName $serviceName

我的诊断文件看起来像

<?xml version="1.0" encoding="utf-8"?>
<DiagnosticsConfiguration  xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
  <PublicConfig>
    <WadCfg>
      <DiagnosticMonitorConfiguration overallQuotaInMB="4096">
        <DiagnosticInfrastructureLogs scheduledTransferLogLevelFilter="Error"/>
        <Logs scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Error" />
        <Directories scheduledTransferPeriod="PT1M">
          <IISLogs containerName ="wad-iis-logfiles" />
          <FailedRequestLogs containerName ="wad-failedrequestlogs" />
        </Directories>
        <WindowsEventLog scheduledTransferPeriod="PT1M" >
          <DataSource name="Application!*" />
        </WindowsEventLog>
        <CrashDumps containerName="wad-crashdumps" dumpType="Mini">
          <CrashDumpConfiguration processName="WaIISHost.exe"/>
          <CrashDumpConfiguration processName="WaWorkerHost.exe"/>
          <CrashDumpConfiguration processName="w3wp.exe"/>
        </CrashDumps>
        <PerformanceCounters scheduledTransferPeriod="PT1M">
          <PerformanceCounterConfiguration counterSpecifier="\Memory\Available MBytes" sampleRate="PT3M" />
          <PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\ISAPI Extension Requests/sec" sampleRate="PT3M" />
          <PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\Bytes Total/Sec" sampleRate="PT3M" />
          <PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Requests/Sec" sampleRate="PT3M" />
          <PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Errors Total/Sec" sampleRate="PT3M" />
          <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Queued" sampleRate="PT3M" />
          <PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Rejected" sampleRate="PT3M" />
          <PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT3M" />
        </PerformanceCounters>
      </DiagnosticMonitorConfiguration>
    </WadCfg>
  </PublicConfig>
  <PrivateConfig>
    <StorageAccount name="" key="" endpoint="" />
  </PrivateConfig>
  <IsEnabled>true</IsEnabled>
</DiagnosticsConfiguration>

2 个答案:

答案 0 :(得分:1)

我认为问题是您在诊断配置文件(.wadcfgx)中有一个空的Storage Accout标记。

如果您通过Visual Studio部署云服务,则可以进行一些更改来修复该错误: (由于.cscfg文件中的诊断连接字符串优先于.wadcfgx文件中的存储帐户,建议您在&#34; .cscfg&#34;而不是&#34; .wadcfgx&#34中引入存储帐户名称;)

  • 首先,在“.cscfg”文件的连接字符串中引入存储帐户名称。

        <ConfigurationSettings>
        <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"
        value="DefaultEndpointsProtocol=https;
        AccountName=TestAccountName;
        AccountKey=abcdefg****************==" />
    
  • 其次,从诊断配置文件中删除<StorageAccount/>标记。

有关详细信息,请参阅https://pawanpalblog.wordpress.com/2015/10/26/set-azureservicediagnosticsextension/https://azure.microsoft.com/en-us/documentation/articles/vs-azure-tools-diagnostics-for-cloud-services-and-virtual-machines/

希望这会有所帮助。

答案 1 :(得分:0)

在启用诊断扩展之前,您需要完成3个先决条件。

  1. 为云服务分配角色。以WorkerRole1为例。请参阅cloud-services-dotnet-diagnostics步骤1:创建工作者角色。创建云服务和workerRole。在“发布”页面中为您的云服务设置workerrole。 enter image description here

  2. 请注意上图中的环境值。您将在-Slot Staging

  3. 中使用它
  4. 对诊断文件进行排序。使用@Derek中的解决方案。改成 <PrivateConfig><ConfigurationSettings><Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=; AccountKey=" /></ConfigurationSettings> </PrivateConfig>

  5. 运行代码(2个步骤):

    $storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
    
    $role_diagconfig = New-AzureServiceDiagnosticsExtensionConfig -Role "WorkerRole1" -DiagnosticsConfigurationPath $diagnosticFileLocation -StorageContext $storageContext 
    
    Set-AzureServiceDiagnosticsExtension -DiagnosticsConfiguration $role_diagconfig  -ServiceName $service_name -Slot Staging
    

    或1步简化:

    $storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
    
    Set-AzureServiceDiagnosticsExtension -StorageContext $storageContext -DiagnosticsConfigurationPath $diagnosticFileLocation -ServiceName $serviceName -Slot Staging -Role WorkerRole1