简体   繁体   English

无法在Azure上为云服务启用AzureServiceDiagnosticsExtension

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

I am unable to set the diagnostic extension for my cloud service via a powershell command. 我无法通过powershell命令为我的云服务设置诊断扩展。 I am getting following error: 我收到以下错误:

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 Command to enable diagnostics for Cloud Service Powershell命令为云服务启用诊断

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

My diagnostic file looks like 我的诊断文件看起来像

<?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>

I think the problem is that you are having an empty Storage Accout tag in the Diagnostics Configuration file(.wadcfgx). 我认为问题在于您在“诊断配置”文件(.wadcfgx)中具有空的Storage Accout标记。

If you deploy your cloud service through Visual Studio, you can make few changes to fix the bug: (Since the diagnostics connection string in the .cscfg file takes precedence over the storage account in the .wadcfgx file, suggest you introduce the storage account name in ".cscfg" rather than ".wadcfgx") 如果您通过Visual Studio部署云服务,则可以进行一些更改以修复该错误:(由于.cscfg文件中的诊断连接字符串优先于.wadcfgx文件中的存储帐户,因此建议您引入存储帐户名称在“ .cscfg”而不是“ .wadcfgx”中)

  • First, introduce the storage account name in the connection string of the “.cscfg” file. 首先,在“ .cscfg”文件的连接字符串中引入存储帐户名称。

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

Refer to https://pawanpalblog.wordpress.com/2015/10/26/set-azureservicediagnosticsextension/ and https://azure.microsoft.com/en-us/documentation/articles/vs-azure-tools-diagnostics-for-cloud-services-and-virtual-machines/ for more details. 请参阅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 /了解更多详细信息。

Hope this helps. 希望这可以帮助。

Before you enable the diagnostic extension, you need to finish 3 prerequisites. 在启用诊断扩展之前,您需要完成3先决条件。

  1. Assign a role to the cloud service. 为云服务分配角色。 WorkerRole1 as a example. 以WorkerRole1为例。 Refer to cloud-services-dotnet-diagnostics Step 1: Create a Worker Role. 请参阅cloud-services-dotnet-diagnostics步骤1:创建辅助角色。 Create a cloud service and a workerRole. 创建一个云服务和一个workerRole。 Set a workerrole for your cloud service in the Publish page. 在“发布”页面中为您的云服务设置一个工作角色。 在此处输入图片说明

  2. Note the Environment value from the above image. 注意上图的环境值。 You will use it in -Slot Staging 您将在-Slot Staging使用它

  3. Sort your diagnostic file. 排序诊断文件。 Use the solution from @Derek. 使用@Derek的解决方案。 Change to <PrivateConfig><ConfigurationSettings><Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=; AccountKey=" /></ConfigurationSettings> </PrivateConfig> 更改为<PrivateConfig><ConfigurationSettings><Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=; AccountKey=" /></ConfigurationSettings> </PrivateConfig>

Run the code(2 steps): 运行代码(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

Or 1 step simplify : 或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.

相关问题 无法为 Azure 云服务(经典)启用反恶意软件 - Unable to enable AntiMalware for Azure Cloud Service (Classic) Azure PowerShell Cmdlet和设置服务诊断(Set-AzureServiceDiagnosticsExtension) - Azure PowerShell Cmdlets and Setting Service Diagnostics (Set-AzureServiceDiagnosticsExtension) 在Azure Cloud Service中启用.NET 3.5功能 - Enable .NET 3.5 Features in Azure Cloud Service 无法为Azure云服务设置通配符SSL - Unable to Setup Wildcard SSL for Azure Cloud Service 无法连接到已部署的Azure云服务 - Unable to connect to deployed Azure Cloud service 无法访问Azure云服务上的远程桌面 - Unable to access Remote Desktop on Azure Cloud Service 在Azure云服务中看不到应用程序错误 - Unable to see application errors in Azure cloud service 在Azure云服务上启用OPTIONS方法(以启用CORS) - Enabling OPTIONS method on Azure Cloud Service (to enable CORS) 如何在MSBuild构建的Azure Cloud Service包中启用远程调试 - How to enable remote debugging in Azure Cloud Service package built by MSBuild 通过脚本在 Azure 云服务经典上启用/禁用反恶意软件扩展 - Enable/disable antimalware extension on Azure Cloud Service classic via script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM