2

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 !

user3732793
  • 1,699
  • 4
  • 24
  • 53

1 Answers1

1

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.
Harshita Singh
  • 4,590
  • 1
  • 10
  • 13
  • thanks for your detailed answer unfortunatetly "an error has occured does not say much" right ?edited the question with error output – user3732793 Aug 31 '20 at 17:52
  • Do you have a container named 'azuritstore'? – Harshita Singh Aug 31 '20 at 17:57
  • Can you install Azurite by following https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite#clone-build-and-run-azurite-from-the-github-repository? And check it by running this cli command `azurite --silent --location c:\azurite --debug c:\azurite\debug.log`? – Harshita Singh Aug 31 '20 at 18:02
  • thanks it looked promissing. Unfortunatetly now Visual Studio complains it can not start storage emulator. It shouldn't do that as I have azurite in VS Code or with your command elsewhere. Any hint how to hinder VS 2019 to start azure storage emulator ? – user3732793 Sep 01 '20 at 08:37
  • it was a problem with the Visual Studio Code plugin. Disabling that and running your command did the Trick ! – user3732793 Sep 01 '20 at 09:22