// Core references from here
        /// <summary>
        /// Logs exceptions to blob storage (useful for logging exceptions without delay before role crashes).
        /// See: http://weblogs.thinktecture.com/cweyer/2011/01/trying-to-troubleshoot-windows-azure-compute-role-startup-issues.html
        /// </summary>
        /// <param name="ex">The exception to log to blob storage</param>
        public static void WriteExceptionToBlobStorage(Exception ex)
        {
            var storageAccount = CloudStorageAccount.Parse(AzureRoleEnvironment.GetConfigurationSettingValue(Constants.DiagnosticsConnectionStringKey));

            var container = storageAccount.CreateCloudBlobClient().GetContainerReference("exceptions");

            container.CreateIfNotExist();

            var blob = container.GetBlobReference(string.Format("exception-{0}-{1}.log", AzureRoleEnvironment.CurrentRoleInstanceId, DateTime.UtcNow.Ticks));

            blob.UploadText(ex.ToString());
        }
Exemple #2
0
 private static string Get(string key)
 {
     return(AzureRoleEnvironment.GetConfigurationSettingValue(key));
 }