0

我正在尝试将我的日志文件添加到 blob 存储。当试图在 Global.asax.cs 中获取 ConnectionString 时,我从 oriented here 收到此错误:

DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnostics);

我该如何解决这个问题。“Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString”在 ServiceConfiguration.Cloud.cscfg 和 ServiceConfiguration.Local.cscfg

给出更多解释:

System.ArgumentOutOfRangeException was unhandled
  HResult=-2146233086
  Message=Invalid syntax for directory path ''
Parameter name: initialConfiguration
  Source=Microsoft.WindowsAzure.Diagnostics
  ParamName=initialConfiguration
  StackTrace:
       at Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorConfiguration.Validate(String paramName, Nullable`1 resourceSize)
       at Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.StartWithExplicitConfiguration(DiagnosticMonitorStartupInfo startupInfo, DiagnosticMonitorConfiguration initialConfiguration)
       at Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.Start(CloudStorageAccount storageAccount, DiagnosticMonitorConfiguration initialConfiguration)
       at Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.Start(String diagnosticsStorageAccountConfigurationSettingName, DiagnosticMonitorConfiguration initialConfiguration)
       at Project.Web.WebRole.OnStart() in Global.asax.cs:line 104
       at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
       at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRole(RoleType roleType)
       at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<InitializeRole>b__0()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
4

1 回答 1

0

看起来您正在正确检索连接字符串,但您的诊断配置无效。您为目录配置设置了什么?

我建议不要通过代码设置诊断配置,而是使用 wadcfg 文件 ( http://msdn.microsoft.com/en-us/library/windowsazure/hh411551.aspx ),或者使用 Visual Studio (参见http://weblogs. asp.net/scottgu/archive/2013/04/30/announcing-the-release-of-windows-azure-sdk-2-0-for-net.aspx,特别是“云服务:改进的诊断支持”部分)。

于 2013-09-09T15:15:42.443 回答