1
votes

I created an Azure function app locally in Visual Studio 2017(Not Azure portal) by following the steps at the following URL.

https://blogs.msdn.microsoft.com/appserviceteam/2017/03/16/publishing-a-net-class-library-as-a-function-app

I followed the steps exactly to create a function that has a “ServiceBusTopicTrigger”. I added the following to my function.json

{
    “disabled”: false,
    “bindings”: [
        {
            “name”: “mySbMsg”,
            “type”: “serviceBusTrigger”,
            “direction”: “in”,
            “topicName”: “negotiatedaddcharge_test”,
            “subscriptionName”: “clientdispatches”,
            “connection”: “servicebusnac”,
            “accessRights”: “manage”
        }
    ]
}

My appsenttings.json has the following

{
    “IsEncrypted”: true,
    “Values”: {
        “servicebusnac”: “Endpoint=MyCompanyEndPointPlaceHolder”
    }
}

When I run the function in Visual Studio I keep getting an error message “Microsoft.Azure.WebJobs.ServiceBus: Microsoft Azure WebJobs SDK ServiceBus connection string ‘AzureWebJobsservicebusnac’ is missing or empty.”

Just for the heck of it I added another entry to the values collection with the name “AzureWebJobsservicebusnac” but still the same message shows up. Is there something that I am doing wrong?

Also how do you unit test this function? I cannot Access any function in the csx file in my unit test project.

Thanks.

Edited: I added information to make it clear that I am creating the function in Visual Studio rather than the Azure portal.

2
Edit: The function runs fine in the portal. The problem I am facing is when I am trying to run it locally in visual studio based on the info in the blog post.Sunil
Please edit the actual question with the above critical details rather than appending a comment. I think you will find that answers to your question will more accurately address your specific issue.JTW

2 Answers

3
votes

Function App will search for your Service Bus connection strings in Environment variables. You can set those from Azure portal:

  1. Go to your Function App.
  2. Select Platform features tab above the editor.
  3. Click Application settings.
  4. Under App settings section add an entry with connection name and string.

The appsettings.json file is used to support local development only, and settings defined there are not published to Azure.

0
votes

The solution is simple; I actually ran into this myself and it had me completely stumped for a while.

In your appsettings.json, change "IsEncrypted" from true to false. This should fix the issue you're seeing.

The error messages are less than ideal for this scenario; the Azure Functions team already has a bugfix in for it.

Hope this helps anyone who runs into this issue. (I swear, it was a week before I figured this out, and not without help.)