簡體   English   中英

無法在Azure上為雲服務啟用AzureServiceDiagnosticsExtension

[英]Unable to enable AzureServiceDiagnosticsExtension for Cloud Service on Azure

我無法通過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.

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>

我認為問題在於您在“診斷配置”文件(.wadcfgx)中具有空的Storage Accout標記。

如果您通過Visual Studio部署雲服務,則可以進行一些更改以修復該錯誤:(由於.cscfg文件中的診斷連接字符串優先於.wadcfgx文件中的存儲帳戶,因此建議您引入存儲帳戶名稱在“ .cscfg”而不是“ .wadcfgx”中)

  • 首先,在“ .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/zh-cn/documentation/articles/vs-azure-tools-diagnostics-for -cloud-services-and-virtual-machines /了解更多詳細信息。

希望這可以幫助。

在啟用診斷擴展之前,您需要完成3先決條件。

  1. 為雲服務分配角色。 以WorkerRole1為例。 請參閱cloud-services-dotnet-diagnostics步驟1:創建輔助角色。 創建一個雲服務和一個workerRole。 在“發布”頁面中為您的雲服務設置一個工作角色。 在此處輸入圖片說明

  2. 注意上圖的環境值。 您將在-Slot Staging使用它

  3. 排序診斷文件。 使用@Derek的解決方案。 更改為<PrivateConfig><ConfigurationSettings><Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=; AccountKey=" /></ConfigurationSettings> </PrivateConfig>

運行代碼(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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM