我正在尝试将我的日志文件添加到blob存储中。当试图在Global.asax.cs中获取ConnectionString时,我从这里得到了这个错误:
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:
答案 0 :(得分: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,特别是“云服务:改进的诊断支持”部分)