Microsoft.WindowsAzure.Storage: Server encountered an internal error without telling the root cause

3.2k Views Asked by At

Locally I have created with azurite a Blob Storage container and I can write/delete files with Storarge Explorer.

This code starts fine but ends after a view seconds with unhandled exception

using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;


namespace WatchStorage
{
    #region Constructor
    public class WatchStorageFunctions
    {
        private ILogger Logger { get; set; }
       
        public WatchStorageFunctions(ILogger<WatchStorageFunctions> logger)
        {
            this.Logger = logger;
        }
        #endregion

        [FunctionName("TaskWatchWebjobs")]
         public void RunTaskWatchWebjobs([BlobTrigger("azuritstore/{name}", Connection = "AzureWebJobsStorage")]Stream myBlob, string name)
        {
            this.Logger.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
        }
    }
}

this is the local.settings.json

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "AzureWebJobsDashboard": "",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "StorageConnectionString": "UseDevelopmentStorage=true"
  }
}   

the error message is just

[] Host lock lease acquired by instance ID '00000000000000000000000049821116'.
[] An unhandled exception has occurred. Host is shutting down.
[] Microsoft.WindowsAzure.Storage: Server encountered an internal error. Please try again after some time.
[] Stopping host...
[] Stopping JobHost
[] Job host stopped
[] Host shutdown completed.

I am new to this stuff and would like to have a more detailed error message. Is that possible ? Any further hint is greatly appreciated !

1

There are 1 best solutions below

5
On BEST ANSWER

Yes, you can see detailed error message in your local debugging. I have created a Azure Blob Trigger on my end and will show you how you can see detailed errors. Please check below:

  1. Upload a blob in the container mentioned in your code (it is samples-workitems for me):

enter image description here

  1. Add try-catch and logging statements like below:

enter image description here

  1. Now, you will be able to see the log errors in the VS Console:

enter image description here

  1. For error messages in Hosted Function App, you will be able to see logs on the portal in Function App > FUNCTION_APP_NAME > FUNCTION_NAME > Code + Test > Logs Pane at the bottom.