我正在從Microsoft的一個示例中演示如何使用自動縮放(http://www.windowsazure.com/en-us/develop/net/how-to-guides/autoscaling/)。安裝在雲上的工作者角色生成性能計數器,在本地,控制檯應用程序讀取此計數器並應用自動調節。嘗試讀取性能計數器時出現Azure自動縮放異常
一切看起來不錯,性能計數器可從WADPerformanceCountersTable中獲得,控制檯應用程序可以正確訪問存儲,但無法在WADPerformanceCountersTable中找到工作者角色。這是所生成的例外:
Autoscaling General Error: 2001 :
Microsoft.Practices.EnterpriseLibrary.WindowsAzure.Autoscaling.DataPointsCollection.DataPointsCollectionException:
Could not retrieve performance counter with name '\Processor(_Total)\% Processor Time'
for target 'WorkerRoleExample' from the WADPerformanceCountersTable table. --->
System.ArgumentOutOfRangeException: Could not retrieve the role with alias 'WorkerRoleExample' from the service information store.
Please review the service information store to fix this.
自動擴充應用程序塊的配置文件(兩個文件控制檯應用程序的一部分):
rules.xml中:
<?xml version="1.0" encoding="utf-8" ?>
<rules xmlns="http://schemas.microsoft.com/practices/2011/entlib/autoscaling/rules">
<constraintRules>
<rule name="default" enabled="true" rank="1" description="The default constraint rule">
<actions>
<range min="1" max="2" target="WorkerRoleExample"/>
</actions>
</rule>
</constraintRules>
<reactiveRules>
<rule name="ScaleUpOnHighUtilization" rank="10" description="Scale up the web role" enabled="true" >
<when>
<any>
<greaterOrEqual operand="WebRoleA_CPU_Avg_5m" than="60"/>
</any>
</when>
<actions>
<scale target="WorkerRoleExample" by="1"/>
</actions>
</rule>
<rule name="ScaleDownOnLowUtilization" rank="10" description="Scale up the web role" enabled="true" >
<when>
<all>
<less operand="WebRoleA_CPU_Avg_5m" than="60"/>
</all>
</when>
<actions>
<scale target="WorkerRoleExample" by="-1"/>
</actions>
</rule>
</reactiveRules>
<operands>
<performanceCounter alias="WebRoleA_CPU_Avg_5m"
performanceCounterName="\Processor(_Total)\% Processor Time"
source ="WorkerRoleExample"
timespan="00:05:00" aggregate="Average"/>
</operands>
</rules>
的services.xml:
<?xml version="1.0" encoding="utf-8" ?>
<serviceModel xmlns="http://schemas.microsoft.com/practices/2011/entlib/autoscaling/serviceModel">
<subscriptions>
<subscription name="TestingWorkerRole"
certificateThumbprint="**************"
subscriptionId="**************"
certificateStoreLocation="CurrentUser"
certificateStoreName="My">
<services>
<service dnsPrefix="**************" slot="Staging">
<roles>
<role alias="AutoscalingApplicationRole"
roleName="WorkerRoleExample"
wadStorageAccountName="targetstorage"/>
</roles>
</service>
</services>
<storageAccounts>
<storageAccount alias="targetstorage"
connectionString="DefaultEndpointsProtocol=https;AccountName=*****;AccountKey=*******">
</storageAccount>
</storageAccounts>
</subscription>
</subscriptions>
</serviceModel>
在雲上運行的工作角色生成一個性能計數器:
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
CreatePerformanceCounters();
return base.OnStart();
}
private static void CreatePerformanceCounters()
{
DiagnosticMonitorConfiguration diagConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
var procTimeConfig = new PerformanceCounterConfiguration();
procTimeConfig.CounterSpecifier = @"\Processor(_Total)\% Processor Time";
procTimeConfig.SampleRate = TimeSpan.FromSeconds(10);
diagConfig.PerformanceCounters.DataSources.Add(procTimeConfig);
diagConfig.PerformanceCounters.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagConfig);
}
您可以包括你的配置文件的休息嗎? 「WorkerRoleExample」在哪裏定義? – greg84 2013-04-21 23:05:22
WorkerRoleExample在另一個解決方案中,它在雲上運行。我已經包含了所有的配置文件。 – Tonatio 2013-04-22 10:11:16