Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning publishing Azure service bus queue trigger can't find named value in local.settings.json

I have a Azure service bus queue trigger function and when I created it it asked me 3 fields, access rights, connection and queue name.

I put in listen for the access rights. For the connection I used the the 'primary connection' name given in the 'RootManageSharedAccessKey' in the service bus I created. It looks something like this

Endpoint=sb://yogaband2017.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=JG0gwJ90bkbGl1BU=

and I created a queue in my service bus called yogaband and that is what I used for the queue name as the third parameter.

My function looks like this

public static class PostEventEmails
{
    [FunctionName("PostEventEmails")]
    public static void Run([ServiceBusTrigger("yogaband2017", AccessRights.Listen, Connection = "Endpoint=sb://yogaband2017.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=gkbGl1BU=")]string myQueueItem, TraceWriter log)
    {
        log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
    }
}

When I publish the function I get this warning

.nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(31,5): warning : Function [PostEventEmails]: cannot find value named 'Endpoint=sb://yogaband2017.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=0bkbGl1BU=' in local.settings.json that matches 'connection' property set on 'serviceBusTrigger' [C:\Users\Source\Workspaces\YogaBand2017\YogaBand2017\PostEventEmails\PostEventEmails.csproj]

and in my site I can pass the queue a message and I see the message in the queue in my Azure portal, but the function isn't picking up the message and processing it. So I still see '1 message' in the active message count in the queue. I assume it would be 0 after the function picks it up and processes it and I would see the log trace in the window? But I don't so I think the connection isn't correct or I didn't configure something correctly but I don't know what!

Here is what I put into the local.settings.json file

{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "Endpoint=sb://yogaband2017.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=bGl1BU=",
"AzureWebJobsDashboard": ""}}

FYI - here is how I send the mesage to the queue in c#

 var queueClient = QueueClient.Create("yogaband2017");
            BrokeredMessage message = new BrokeredMessage("some test message");
            message.MessageId = newEvent.YogaSpaceEventId.ToString();

            queueClient.Send(message);

and in my web.config file I added this

<add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://yogaband2017.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=0gwJ90bkbGl1BU="/>
like image 849
user1186050 Avatar asked Dec 09 '17 01:12

user1186050


People also ask

How do I debug Azure Service Bus locally?

Sign in to the Azure Portal, go to your Service Bus, and send a message to it using the Service Bus Explorer. Your function will be triggered by your Service Bus and the breakpoint will be hit. Or: Open up VS, set a breakpoint in your Azure Function and start debugging.

What is Service Bus queue trigger?

Start process by receiving message in Service Bus. Service Bus triggers are similar to Queue Triggers, in that they allow you to trigger Processes on messages received from a message queue, in this case an Azure Service Bus or Service Bus for Windows Server queue or subscription.

What is host JSON in Azure function?

The host. json metadata file contains configuration options that affect all functions in a function app instance. This article lists the settings that are available starting with version 2. x of the Azure Functions runtime.


1 Answers

Connection property of ServiceBusTrigger should be set to a setting name, not connection string itself:

[ServiceBusTrigger("yogaband2017", AccessRights.Listen, Connection = "MyConn")]

You then define a setting with this name in local.settings.json for local development environment:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "... azure storage connection string ...",
    "MyConn": "... service bus connection string ..."
  }
}

and in App Settings for Azure deployment.

Note that AzureWebJobsStorage is NOT service bus connection.

like image 129
Mikhail Shilkov Avatar answered Oct 01 '22 10:10

Mikhail Shilkov