0
votes

When I updated my Azure Functions project to .net core 2.0, it started failing to trigger upon a message on my Queue.

TranslatorAPI.cs

public static class TranslatorAPI
{
    [FunctionName("TranslatorAPI")]
    public static void Run([QueueTrigger("Translator")]string mySbMsg, TraceWriter log)
    {
        //breakpoint here, but never hit
        CallTranslator callTranslator = new CallTranslator();

        //something
    }
}

local.setting.json

{
  "IsEncrypted": false,
  "Values": {
    "WEBSITE_SLOT_NAME": "Production",
    "FUNCTIONS_EXTENSION_VERSION": "~1",
    "ScmType": "None",
    "WEBSITE_AUTH_ENABLED": "False",
    "FUNCTION_APP_EDIT_MODE": "readwrite",
    "APPINSIGHTS_INSTRUMENTATIONKEY": "<Key>",
    "WEBSITE_NODE_DEFAULT_VERSION": "6.5.0",
    "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "DefaultEndpointsProtocol=https;AccountName=<AccountName>;AccountKey=<Key>",
    "WEBSITE_CONTENTSHARE": "<ShareName>",
    "WEBSITE_SITE_NAME": "<Functions'Name>",
    "<ServiceBusInstanceName>_RootManageSharedAccessKey_SERVICEBUS": "Endpoint=<ConnectionString>",
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=<AccountName>;AccountKey=<Key>",
    "AzureWebJobsDashboard": "DefaultEndpointsProtocol=https;AccountName=<AccountName>;AccountKey=<Key>;BlobEndpoint=<BlobURL>;TableEndpoint=<TableURL>;QueueEndpoint=<QueueURL>;FileEndpoint=<FileURL>"
  }
}

Workaround:

With the latest NuGet package "Microsoft.Azure.WebJobs" 3.0.0-beta4, there is a known issue with handling an extension for ServiceBus connection and project build is to fail at establishing a path for the ServiceBus metadata. Updating these packages from the source Azure App Service:

Microsoft.Azure.WebJobs: 3.0.0-beta4-11131
Microsoft.Azure.WebJobs.Extensions: 3.0.0-beta4-10578
Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator: 1.0.0-beta3
Microsoft.Azure.WebJobs.ServisBus: 3.0.0-beta4-11131

enabled the build succeeded. However, it still cannot receive a message from my queue. Here's the log of function console.

[2018/01/20 0:22:38] Reading host configuration file '<ProjectPath>\bin\Debug\netstandard2.0\host.json'
[2018/01/20 0:22:38] Host configuration file read:
[2018/01/20 0:22:38] {}
[2018/01/20 0:22:40] Loading custom extension 'HttpExtensionConfiguration'
[2018/01/20 0:22:40] Unable to load custom extension type for extension 'HttpExtensionConfiguration' (Type: `Microsoft.Azure.WebJobs.Extensions.Http.HttpExtensionConfiguration, Microsoft.Azure.WebJobs.Extensions.Http, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null`).The type does not exist or is not a valid extension. Please validate the type and assembly names.
[2018/01/20 0:22:40] Loading custom extension 'ServiceBusExtensionConfig'
[2018/01/20 0:22:40] Loaded custom extension: ServiceBusExtensionConfig from '<ProjectPath>\bin\Debug\netstandard2.0\bin\Microsoft.Azure.WebJobs.ServiceBus.dll'
[2018/01/20 0:22:41] Generating 1 job function(s)
[2018/01/20 0:22:42] Starting Host (HostId=<PCName>-1149239943, Version=2.0.11415.0, ProcessId=12536, Debug=False, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=~1)
[2018/01/20 0:22:44] Found the following functions:
[2018/01/20 0:22:44] <Functions'Name>.TranslatorAPI.Run
[2018/01/20 0:22:44]
[2018/01/20 0:22:44] Job host started
[2018/01/20 0:22:44] Host lock lease acquired by instance ID '<ID>'.
Listening on http://localhost:7071/
Hit CTRL-C to exit...

Although it fails to read an extenstion for http trigger type, it succeeds to generate TranslatorAPI.Run.

So what would be a problem here?

EDIT

I assumed the method failed to get the connection string, so I changed the method argument to

public static void Run([QueueTrigger("Translator", Connection = "<ServiceBusInstanceName>_RootManageSharedAccessKey_SERVICEBUS")]string mySbMsg, TraceWriter log)

Then the error changed into

[2018/01/20 1:32:57] Run: Microsoft.Azure.WebJobs.Host: Error indexing method 'TranslatorAPI.Run'. Microsoft.Azure.WebJobs.Host: Failed to validate Microsoft Azure WebJobs SDK <ServiceBusInstanceName>_RootManageSharedAccessKey_SERVICEBUS 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.

Now it seems say my connection string for the ServiceBus is wrong based on the validation of connection string for Azure Storage Account. I'm not sure how to understand what's this meaning and to solve this issue.

1

1 Answers

1
votes

It looks like your connection string for the QueueTrigger is actually a service bus connection string. The QueueTrigger connection string should be in the following format: DefaultEndpointsProtocol=https;AccountName=xxx;AccountKey=xxx;EndpointSuffix=core.windows.net

If you did want to use the service bus queue, you can try using the ServiceBusTrigger instead!