/// <summary> /// Formats an error message corresponding to the provided error code and account. /// </summary> /// <param name="error">The error code as returned by <see cref="TryParseAccount"/> method call.</param> /// <param name="connectionStringName">Friendly connection string name used to format error message</param> /// <returns>Formatted error message with details about reason of the failure and possible ways of mitigation</returns> public static string FormatParseAccountErrorMessage(StorageAccountParseResult error, string connectionStringName) { switch (error) { case StorageAccountParseResult.MissingOrEmptyConnectionStringError: return(String.Format(CultureInfo.CurrentCulture, "Microsoft Azure WebJobs SDK '{0}' connection string is missing or empty. " + "The Microsoft Azure Storage account connection string can be set in the following ways:" + Environment.NewLine + "1. Set the connection string named '{1}' in the connectionStrings section of the .config file in the following format " + "<add name=\"{1}\" connectionString=\"DefaultEndpointsProtocol=http|https;AccountName=NAME;AccountKey=KEY\" />, or" + Environment.NewLine + "2. Set the environment variable named '{1}', or" + Environment.NewLine + "3. Set corresponding property of JobHostConfiguration.", connectionStringName, AmbientConnectionStringProvider.GetPrefixedConnectionStringName(connectionStringName))); case StorageAccountParseResult.MalformedConnectionStringError: return(String.Format(CultureInfo.CurrentCulture, "Failed to validate Microsoft Azure WebJobs SDK {0} connection string. " + "The Microsoft Azure Storage account connection string is not formatted " + "correctly. Please visit https://go.microsoft.com/fwlink/?linkid=841340 for " + "details about configuring Microsoft Azure Storage connection strings.", connectionStringName)); } Debug.Assert(false, "Unsupported case of error message!"); return(String.Empty); }
/// <summary> /// Formats an error message corresponding to the provided error code and account. /// </summary> /// <param name="error">The error code as returned by <see cref="TryParseAccount"/> method call.</param> /// <param name="connectionStringName">Friendly connection string name used to format error message</param> /// <returns>Formatted error message with details about reason of the failure and possible ways of mitigation</returns> public static string FormatParseAccountErrorMessage(StorageAccountParseResult error, string connectionStringName) { // Users may accidentally use their real connection strings here, so let's be safe before throwing. connectionStringName = Sanitizer.Sanitize(connectionStringName); switch (error) { case StorageAccountParseResult.MissingOrEmptyConnectionStringError: // We don't want to add 'AzureWebJobs' as a prefix unless it is one of our keys. string prefixedConnectionString = connectionStringName; if (connectionStringName == ConnectionStringNames.Dashboard || connectionStringName == ConnectionStringNames.Storage) { prefixedConnectionString = AmbientConnectionStringProvider.GetPrefixedConnectionStringName(connectionStringName); } return(String.Format(CultureInfo.CurrentCulture, "Microsoft Azure WebJobs SDK '{0}' connection string is missing or empty. " + "The Microsoft Azure Storage account connection string can be set in the following ways:" + Environment.NewLine + "1. Set the connection string named '{1}' in the connectionStrings section of the .config file in the following format " + "<add name=\"{1}\" connectionString=\"DefaultEndpointsProtocol=http|https;AccountName=NAME;AccountKey=KEY\" />, or" + Environment.NewLine + "2. Set the environment variable named '{1}', or" + Environment.NewLine + "3. Set corresponding property of JobHostConfiguration.", connectionStringName, prefixedConnectionString)); case StorageAccountParseResult.MalformedConnectionStringError: return(String.Format(CultureInfo.CurrentCulture, "Failed to validate Microsoft Azure WebJobs SDK {0} connection string. " + "The Microsoft Azure Storage account connection string is not formatted " + "correctly. Please visit https://go.microsoft.com/fwlink/?linkid=841340 for " + "details about configuring Microsoft Azure Storage connection strings.", connectionStringName)); } Debug.Assert(false, "Unsupported case of error message!"); return(String.Empty); }