【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}"
}
]
}
}
【Azure 云服务】Azure Cloud Service (Extended Support) 云服务开启诊断日志插件 WAD Extension (Windows Azure Diagnostic) 无法正常工作的原因的更多相关文章
- Windows Azure中WebSite 网站, Cloud Service 云服务,Virtual Machine 虚拟机的比较
在Windows Azure服务平台里,Web Site特点是: 在Windows Azure上构建高度可扩展的Web站点. 快速.轻松部署一个高度可扩展的云环境,并且可以从很小的规模开始. 使用您所 ...
- [Windows Azure] What is a cloud service?
What is a cloud service? When you create an application and run it in Windows Azure, the code and co ...
- 微软开放技术发布开源 Jenkins 插件以将 Windows Azure Blob 服务用的开作存储库
发布于 2014-02-10 作者 陈 忠岳 持续集成 (CI) 的历史源远流长, 其宗旨在于软件团队在敏捷环境中不断将他们的工作整合为持续构建.管理 CI 进程的工具已存在一段时间.过去几年中 ...
- Windows Azure Cloud Service (41) 修改云服务IIS托管管道模式为4.0经典模式
<Windows Azure Platform 系列文章目录> 这是笔者在之前的项目中遇到的问题,做一下总结,给网友做参考. 在一般情况下,Visual Studio开发的Cloud Se ...
- [Windows Azure] Virtual Machine and Cloud Service Sizes for Windows Azure
Virtual machine size CPU cores Memory OS disk space–cloud services OS disk space–virtual machines Ma ...
- [Windows Azure] How to use the Table Storage Service
How to use the Table Storage Service version 1.7 version 2.0 This guide will show you how to perform ...
- [Windows Azure] Building the web role for the Windows Azure Email Service application - 3 of 5
Building the web role for the Windows Azure Email Service application - 3 of 5. This is the third tu ...
- [Windows Azure] How to Monitor Cloud Services
How to Monitor Cloud Services To use this feature and other new Windows Azure capabilities, sign up ...
- [Windows Azure] .NET Multi-Tier Application Using Storage Tables, Queues, and Blobs - 1 of 5
.NET Multi-Tier Application Using Storage Tables, Queues, and Blobs - 1 of 5 This tutorial series sh ...
随机推荐
- 一篇文章扒掉“桥梁Handler”的底裤
Android跨进程要掌握的是Binder, 而同一进程中最重要的应该就是Handler 消息通信机制了.我这么说,大家不知道是否认同,如果认同,还希望能给一个关注哈. 什么是Handler? Han ...
- C++设计模式 - 组合模式(Composite)
数据结构模式 常常有一-些组件在内部具有特定的数据结构,如果让客户程序依赖这些特定的数据结构,将极大地破坏组件的复用.这时候,将这些特定数据结构封装在内部,在外部提供统一的接口,来实现与特定数据结构无 ...
- git中的文件操作
现在我们的机器上有了一个 真实项目 的 Git 仓库,并从这个仓库中检出了所有文件的 工作副本. 通常,你会对这些文件做些修改,每当完成了一个阶段的目标,想要将记录下它时,就将它提交到仓库. git中 ...
- 使用.Net6中的System.Text.Json遇到几个常见问题及解决方案
前言 以前.NetCore是不内置JSON库的,所以大家都用Newtonsoft的JSON库,而且也确实挺好用的,不过既然官方出了标准库,那更方便更值得我们多用用,至少不用每次都nuget安装Newt ...
- [SPDK/NVMe存储技术分析]012 - 用户态ibv_post_send()源码分析
OFA定义了一组标准的Verbs,并提供了一个标准库libibvers.在用户态实现NVMe over RDMA的Host(i.e. Initiator)和Target, 少不了要跟OFA定义的Ver ...
- 记一次Prometheus代理性能优化问题
最近有做一个Prometheus metrics代理的一个小项目,暂称为prom-proxy,目的是为了解析特定的指标(如容器.traefik.istio等指标),然后在原始指标中加入应用ID(当然还 ...
- 关于如何让写自然溢出hash的无辜孩子见祖宗这件事
关于如何让写自然溢出hash的无辜孩子见祖宗这件事 来源博客 这几天考试连着好几次被卡hash卡到死. 我谔谔,为什么连hash都要卡. 码力弱鸡什么时候才能站起来. 只需要任意两种字符,比如噫呜呜噫 ...
- Windows&Linux文件传输方式总结
在渗透过程中,通常会需要向目标主机传送一些文件,来达到权限提升.权限维持等目的,本篇文章主要介绍一些windows和Linux下常用的文件传输方式. Windows 利用FTP协议上传 在本地或者VP ...
- 【Java面试宝典】说说你对 Spring 的理解,非单例注入的原理?它的生命周期?循环注入的原理, aop 的实现原理,说说 aop 中的几个术语,它们是怎么相互工作的?
AOP与IOC的概念(即spring的核心) IOC:Spring是开源框架,使用框架可以使我们减少工作量,提高工作效率并且它是分层结构,即相对应的层处理对应的业务逻辑,减少代码的耦合度.而sprin ...
- java动态代理--代理接口无实现类
转载:https://blog.csdn.net/weixin_45674354/article/details/103246715 1.接口定义: package cn.proxy; public ...