【Azure 云服务】Azure Cloud Service (Extended Support) 云服务开启诊断日志插件 WAD Extension (Windows Azure Diagnostic) 无法正常工作的原因

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介: 【Azure 云服务】Azure Cloud Service (Extended Support) 云服务开启诊断日志插件 WAD Extension (Windows Azure Diagnostic) 无法正常工作的原因

问题描述

在Azure中国区上面创建一个云服务(外延支持)后,根据官方文档(在云服务(外延支持)中应用 Azure 诊断扩展: https://docs.azure.cn/zh-cn/cloud-services-extended-support/enable-wad),启用了WAD扩展来收集实例的Metrics信息到Stroage Account。根据官方的实例,配置好了公共配置 XML 文件(PublicWadConfig.xsd)专用 XML 配置文件(PrivateConfig.xml)后,在Storage Account中却没有受到指标数据。

相应的配置文件为:

PublicWadConfig.xsd

<?xml version="1.0" encoding="utf-8"?>
<PublicConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
  <WadCfg>
    <DiagnosticMonitorConfiguration overallQuotaInMB="25000">
      <PerformanceCounters scheduledTransferPeriod="PT1M">
        <PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT1M" unit="percent" />
        <PerformanceCounterConfiguration counterSpecifier="\Memory\Committed Bytes" sampleRate="PT1M" unit="bytes"/>
      </PerformanceCounters>
      <EtwProviders>
        <EtwEventSourceProviderConfiguration provider="SampleEventSourceWriter" scheduledTransferPeriod="PT5M">
          <Event id="1" eventDestination="EnumsTable"/>
          <DefaultEvents eventDestination="DefaultTable" />
        </EtwEventSourceProviderConfiguration>
      </EtwProviders>
    </DiagnosticMonitorConfiguration>
  </WadCfg>
</PublicConfig>

PrivateConfig.xml

<?xml version="1.0" encoding="utf-8"?>
<PrivateConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
  <StorageAccount name="stroage account name" key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
</PrivateConfig>

执行的PowerShell命令为:

# 登录中国区Azure
Connect-AzAccount -Environment AzureChinaCloud
# 选择订阅号
Select-AzSubscription -Subscription 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
# 如果没有安装az cloud service模块,用下面命令安装
Install-Module -Name Az.CloudService  -Scope CurrentUser -Repository PSGallery -Force
# Create WAD extension object
$storageAccountKey = Get-AzStorageAccountKey -ResourceGroupName "resource group name" -Name "storage account name"
$configFilePath = "PublicWadConfig.xsd"
$wadExtension = New-AzCloudServiceDiagnosticsExtension -Name "WADExtension" -ResourceGroupName "resource group name" -CloudServiceName "cloud service name" -StorageAccountName "csstorageaccounttest01" -StorageAccountKey $storageAccountKey[0].Value -DiagnosticsConfigurationPath $configFilePath -TypeHandlerVersion "1.5" -AutoUpgradeMinorVersion $true
# Add <privateConfig> settings
$wadExtension.ProtectedSetting = "<Insert WAD Private Configuration as raw string here>"
# Get existing Cloud Service
$cloudService = Get-AzCloudService -ResourceGroup "resource group name" -CloudServiceName "cloud service name"
# Add WAD extension to existing Cloud Service extension object
$cloudService.ExtensionProfile.Extension = $cloudService.ExtensionProfile.Extension + $wadExtension
# Update Cloud Service
$cloudService | Update-AzCloudService

在Cloud Service的Extension页面查看到WADExtention 已经配置好(状态为Success)。

但是在配置的Storage Account中,却迟迟收集到不数据。

问题分析

为了分析这个问题,需要开启应用远程桌面扩展(RDP)查看 WAD插件的日志。相应日志的路径为:

C:\Resources\Directory\<guid>.<webroelx>.DiagnosticStore\WAD0107\Tables

但日志文件为tsf格式,可以通过table2csv.exe 进行转换 (PS: table2csv.exe 文件路径位于 > D:\Packages\Plugins\Microsoft.Azure.Diagnostics.PaaSDiagnostics\<latest extension version>\Monitor\x64\table2csv.exe),使用 <PATH>\table2scv.exe maeventtable.tsf 命令把文件转换为csv格式后 ,即可查看日志内容:

在日志内容中发现:

WinHttpSendRequest failed; URL=https://********************.table.core.windows.net
Failed to send bytes to XTable WADPerformanceCountersTable as Xstore rejected the request; Status=12007
Retry:#0; failed to send out data; XTable WADPerformanceCountersTable; PartitionKey 0637848351000000000

因为中国区Storage Account的Endpoint与Global不一样,消息中发现的Endpoint为 core.windows.net, 而中国区的endpoint为 core.chinacloudapi.cn。由于在添加的配置文件中,并没有为Storage Account特别指定Endpoint,导致系统默认使用了Global地址。

 

所以解决问题的方案就是在PrivateConfig.xml文件中添加Endpoint [ endpoint="https://core.chinacloudapi.cn" ]。

 

问题解决

修改PrivateConfig文件,在StorageAccount 节点中添加 endpoint,修改后的文件为:

PrivateConfig.xml

<?xml version="1.0" encoding="utf-8"?>
<PrivateConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
  <StorageAccount name="stroage account name" key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" endpoint="https://core.chinacloudapi.cn" />
</PrivateConfig>

在Powershell的脚本中可以通过  Get-Content -Path privateConfig.xml 来获取上文内容,并赋值给 $wadExtension.ProtectedSetting。

完整的PowerShell脚本为:

Connect-AzAccount -Environment AzureChinaCloud
# 选择订阅号
Select-AzSubscription -Subscription 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
# 如果没有安装az cloud service模块,用下面命令安装
Install-Module -Name Az.CloudService  -Scope CurrentUser -Repository PSGallery -Force
# Create WAD extension object
$storageAccountKey = Get-AzStorageAccountKey -ResourceGroupName "resource group name" -Name "storage account name"
$configFilePath = "PublicWadConfig.xsd"
$wadExtension = New-AzCloudServiceDiagnosticsExtension -Name "WADExtension" -ResourceGroupName "resource group name" -CloudServiceName "cloud service name" -StorageAccountName "csstorageaccounttest01" -StorageAccountKey $storageAccountKey[0].Value -DiagnosticsConfigurationPath $configFilePath -TypeHandlerVersion "1.5" -AutoUpgradeMinorVersion $true
# Add <privateConfig> settings
$wadExtension.ProtectedSetting = Get-Content -Path PrivateConfig.xml
# Get existing Cloud Service
$cloudService = Get-AzCloudService -ResourceGroup "resource group name" -CloudServiceName "cloud service name"
# Add WAD extension to existing Cloud Service extension object
$cloudService.ExtensionProfile.Extension = $cloudService.ExtensionProfile.Extension + $wadExtension
# Update Cloud Service
$cloudService | Update-AzCloudService

最终,通过 Microsoft Azure Storage Explorer工具查看Cloud Service的Metrics数据。

 

收集Metrics数据成功!

 

附件一:WAD Extension不允许使用重复的名称,所以可以通过名称过滤掉需要删除的Extension名称后,执行以下的脚本

# Get existing Cloud Service
$cloudService = Get-AzCloudService -ResourceGroup "your resource group" -CloudServiceName "cloud service name"
$cloudService.ExtensionProfile.Extension = $cloudService.ExtensionProfile.Extension | Where-Object { $_.Name -ne "WADExtension" }
# Update Cloud Service
$cloudService | Update-AzCloudService

 

参考资料

在云服务(外延支持)中应用 Azure 诊断扩展:https://docs.azure.cn/zh-cn/cloud-services-extended-support/enable-wad

Private Config Schem: https://docs.microsoft.com/en-us/azure/azure-monitor/agents/diagnostics-extension-schema-windows#example-configuration

"PrivateConfig" {
    "storageAccountName": "diagstorageaccount",
    "storageAccountKey": "{base64 encoded key}",
    "storageAccountEndPoint": "https://core.windows.net",
    "storageAccountSasToken": "{sas token}",
    "EventHub": {
        "Url": "https://myeventhub-ns.servicebus.windows.net/diageventhub",
        "SharedAccessKeyName": "SendRule",
        "SharedAccessKey": "{base64 encoded key}"
    },
    "AzureMonitorAccount": {
        "ServicePrincipalMeta": {
            "PrincipalId": "{Insert service principal client Id}",
            "Secret": "{Insert service principal client secret}"
        }
    },
    "SecondaryStorageAccounts": {
        "StorageAccount": [
            {
                "name": "secondarydiagstorageaccount",
                "key": "{base64 encoded key}",
                "endpoint": "https://core.windows.net",
                "sasToken": "{sas token}"
            }
        ]
    },
    "SecondaryEventHubs": {
        "EventHub": [
            {
                "Url": "https://myeventhub-ns.servicebus.windows.net/secondarydiageventhub",
                "SharedAccessKeyName": "SendRule",
                "SharedAccessKey": "{base64 encoded key}"
            }
        ]
    }
}

 

 

相关实践学习
【涂鸦即艺术】基于云应用开发平台CAP部署AI实时生图绘板
【涂鸦即艺术】基于云应用开发平台CAP部署AI实时生图绘板
相关文章
|
8月前
|
数据库连接 测试技术 Windows
【YashanDB知识库】windows配置ODBC跟踪日志, 使用日志定位问题
【YashanDB知识库】windows配置ODBC跟踪日志, 使用日志定位问题
|
12月前
|
安全 Windows
【Azure Cloud Service】在Windows系统中抓取网络包 ( 不需要另外安全抓包工具)
通常,在生产环境中,为了保证系统环境的安全和纯粹,是不建议安装其它软件或排查工具(如果可以安装,也是需要走审批流程)。 本文将介绍一种,不用安装Wireshark / tcpdump 等工具,使用Windows系统自带的 netsh trace 命令来获取网络包的步骤
259 32
|
11月前
|
缓存 安全 网络协议
使用事件日志识别常见 Windows 错误
事件查看器是Windows操作系统中的标准诊断工具,用于记录系统事件,包括硬件问题、软件中断和系统行为等详细信息。通过分析这些日志,管理员能够追踪和解决系统错误。访问方法包括使用快捷键Win + R输入eventvwr.msc,或通过控制面板进入。事件查看器中的每条记录包含事件ID、来源和描述,帮助识别和解决问题。常见错误如蓝屏死机、DLL错误、驱动程序错误等,可通过更新驱动程序、运行系统诊断、使用恢复功能等方式解决。
783 4
|
C# Windows
【Azure App Service】在App Service for Windows上验证能占用的内存最大值
根据以上测验,当使用App Service内存没有达到预期的值,且应用异常日志出现OutOfMemory时,就需要检查Platform的设置是否位64bit。
196 11
|
12月前
|
监控 安全 网络安全
使用EventLog Analyzer日志分析工具监测 Windows Server 安全威胁
Windows服务器面临多重威胁,包括勒索软件、DoS攻击、内部威胁、恶意软件感染、网络钓鱼、暴力破解、漏洞利用、Web应用攻击及配置错误等。这些威胁严重威胁服务器安全与业务连续性。EventLog Analyzer通过日志管理和威胁分析,有效检测并应对上述威胁,提升服务器安全性,确保服务稳定运行。
376 2
|
网络安全 API 数据安全/隐私保护
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Windows)
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Windows)
151 0
|
网络安全
【Azure Service Bus】启用诊断日志来获取客户端访问Azure Service Bus的IP地址 [2024-03-26 实验结果失败]
【Azure Service Bus】启用诊断日志来获取客户端访问Azure Service Bus的IP地址 [2024-03-26 实验结果失败]
129 0
|
Shell PHP Windows
【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Windows directory.
【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Windows directory.
147 0
|
6月前
|
监控 容灾 算法
阿里云 SLS 多云日志接入最佳实践:链路、成本与高可用性优化
本文探讨了如何高效、经济且可靠地将海外应用与基础设施日志统一采集至阿里云日志服务(SLS),解决全球化业务扩展中的关键挑战。重点介绍了高性能日志采集Agent(iLogtail/LoongCollector)在海外场景的应用,推荐使用LoongCollector以获得更优的稳定性和网络容错能力。同时分析了多种网络接入方案,包括公网直连、全球加速优化、阿里云内网及专线/CEN/VPN接入等,并提供了成本优化策略和多目标发送配置指导,帮助企业构建稳定、低成本、高可用的全球日志系统。
753 54

热门文章

最新文章