在雲端服務 (延伸支援) 中套用 Microsoft Azure 診斷延伸模組
您可以監視任何雲端服務的關鍵效能計量。 每個雲端服務角色都會收集最少資料:CPU 使用量、網路使用量和磁碟使用狀況。 如果雲端服務已將 Microsoft.Azure.Diagnostics 延伸模組套用至角色,則該角色可以收集其他資料點。 如需詳細資訊,請參閱延伸模組概觀
您可以透過 PowerShell 或 ARM 範本為雲端服務 (延伸支援) 啟用 Microsoft Azure 診斷延伸模組
使用 PowerShell 套用 Microsoft Azure 診斷延伸模組
# Create WAD extension object
$storageAccountKey = Get-AzStorageAccountKey -ResourceGroupName "ContosOrg" -Name "contosostorageaccount"
$configFilePath = "<Insert WAD public configuration file path>"
$wadExtension = New-AzCloudServiceDiagnosticsExtension -Name "WADExtension" -ResourceGroupName "ContosOrg" -CloudServiceName "ContosoCS" -StorageAccountName "contosostorageaccount" -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 "ContosOrg" -CloudServiceName "ContosoCS"
# Add WAD extension to existing Cloud Service extension object
$cloudService.ExtensionProfile.Extension = $cloudService.ExtensionProfile.Extension + $wadExtension
# Update Cloud Service
$cloudService | Update-AzCloudService
執行下列 PowerShell 命令,以下載公用組態檔結構描述定義:
(Get-AzureServiceAvailableExtension -ExtensionName 'PaaSDiagnostics' -ProviderNamespace 'Microsoft.Azure.Diagnostics').PublicConfigurationSchema | Out-File -Encoding utf8 -FilePath 'PublicWadConfig.xsd'
以下是公用設定 XML 檔案的範例
<?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>
執行下列 PowerShell 命令,以下載私人設定檔結構描述定義:
(Get-AzureServiceAvailableExtension -ExtensionName 'PaaSDiagnostics' -ProviderNamespace 'Microsoft.Azure.Diagnostics').PrivateConfigurationSchema | Out-File -Encoding utf8 -FilePath 'PrivateWadConfig.xsd'
以下是私人設定 XML 檔案的範例
<?xml version="1.0" encoding="utf-8"?>
<PrivateConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<StorageAccount name="string" key="string" />
<AzureMonitorAccount>
<ServicePrincipalMeta>
<PrincipalId>string</PrincipalId>
<Secret>string</Secret>
</ServicePrincipalMeta>
</AzureMonitorAccount>
<SecondaryStorageAccounts>
<StorageAccount name="string" />
</SecondaryStorageAccounts>
<SecondaryEventHubs>
<EventHub Url="string" SharedAccessKeyName="string" SharedAccessKey="string" />
</SecondaryEventHubs>
</PrivateConfig>
使用 ARM 範本套用 Microsoft Azure 診斷延伸模組
"extensionProfile": {
"extensions": [
{
"name": "Microsoft.Insights.VMDiagnosticsSettings_WebRole1",
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.Azure.Diagnostics",
"type": "PaaSDiagnostics",
"typeHandlerVersion": "1.5",
"settings": "Include PublicConfig XML as a raw string",
"protectedSettings": "Include PrivateConfig XML as a raw string”",
"rolesAppliedTo": [
"WebRole1"
]
}
}
]
},
下一步
- 檢閱雲端服務 (延伸支援) 的部署必要條件。
- 檢閱雲端服務 (延伸支援) 的常見問題集。
- 使用 Azure 入口網站、PowerShell、範本或 Visual Studio 部署雲端服務 (延伸支援)。