2013-07-09 46 views
0

我試圖獲得一個天藍色的角色運行 - 它在模擬器上運行,但不在Azure上運行。所以我試圖將Tracing集成到我的項目中。我首先嚐試了一個簡單的測試項目(完美工作),但在我的「真實」項目中,我沒有得到結果。Azure跟蹤結果未上傳

這裏是我的文件:

的app.config

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.diagnostics> 
    <trace> 
     <listeners> 
     <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics"> 
      <filter type="" /> 
     </add> 
     </listeners> 
    </trace> 
    </system.diagnostics> 
</configuration> 

ServiceConfiguration.Cloud.cscfg

<?xml version="1.0" encoding="utf-8"?> 
<ServiceConfiguration serviceName="MyServiceName" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="3" osVersion="*" schemaVersion="2013-03.2.0"> 
    <Role name="MyRoleName"> 
    <Instances count="2" /> 
    <ConfigurationSettings> 
     <Setting name="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=<myAccount>;AccountKey=<myKEy==>" /> 
     <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=<myAccount>;AccountKey=<myKEy==>" /> 
    </ConfigurationSettings> 
    </Role> 
</ServiceConfiguration> 

ServiceDefinition.csdef中

<?xml version="1.0" encoding="utf-8"?> 
<ServiceDefinition name="MyServiceName" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2013-03.2.0"> 
    <WorkerRole name="MyRoleName" vmsize="Small"> 
    <Imports> 
     <Import moduleName="Diagnostics" /> 
    </Imports> 
    <Endpoints> 
     <InternalEndpoint name="InternalEndpoint1" protocol="tcp" /> 
    </Endpoints> 
    <ConfigurationSettings> 
     <Setting name="StorageConnectionString" /> 
    </ConfigurationSettings> 
    </WorkerRole> 
</ServiceDefinition> 

我的源代碼( Snippe t):

public override bool OnStart() 
{ 

    ConfigDiagnostics(); 
    Trace.TraceInformation("Initializing storage account"); 

    // Set the maximum number of concurrent connections 
    ServicePointManager.DefaultConnectionLimit = 12; 

    // For information on handling configuration changes 
    // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. 

    return base.OnStart(); 
} 

private void ConfigDiagnostics() 
{ 
    DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration(); 
    config.ConfigurationChangePollInterval = TimeSpan.FromMinutes(1d); 
    config.Logs.BufferQuotaInMB = 500; 
    config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose; 
    config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1d);    

    //DiagnosticMonitor.Start(@"StorageConnectionString", config); 
    DiagnosticMonitor.Start(@"Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", config); 
} 

相同的代碼在一個普通的新Azure項目中工作 - 但不在此項目中。我現在可以發現的唯一區別是:我的「真實」項目在我的run()方法中引發異常。難道我的追蹤結果(來自Trace.WriteLine或Trace.TraceError或Trace.TraceInformation)沒有上傳,因爲Azure實例的異常和回收發生得太快/太早,無法將我的追蹤結果上傳到我的存儲帳戶?或者還有另一點我錯過了?!

最好的問候:)

回答

0

問題是另一個問題:包裝與cspack蔚藍的作用,包裝與Visual Studio的Azure角色有差別再加上我在一個文件包包裝的作用是falty命令。

跟蹤本身的工作方式完全符合我的要求。