question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Functions V2: host.json "extensions" not loading, autoRenewTimeout lock issue

See original GitHub issue

Hi, I am having troubles with my host.json-file, in particular, by loading the contents under the “extensions” tag in the file when having a Azure Function (AF) V2: Service Bus Trigger.

I have cross checked by creating a simple AF V1 and used the following input in my host.json-file:

{
  "serviceBus": {
    "maxConcurrentCalls": 1,
    "autoRenewTimeout": "00:25:00"
  }
}

When spinning up my AF, I am seeing the following image: image

Giving me an indication that it is loaded. I can see that it behaves like I want by handling concurrent calls and locks.

Moving on to V2:

When setting the following text in my host.json-file (Source: :

{
    "version": "2.0",
    "extensions": {
      "eventHubs": {
        "maxBatchSize": 64,
        "prefetchCount": 256,
        "batchCheckpointFrequency": 1
      },
        "http": {
            "routePrefix": "api",
            "maxConcurrentRequests": 5,
            "maxOutstandingRequests": 30
        },
        "queues": {
            "visibilityTimeout": "00:00:10",
            "maxDequeueCount": 3
        },
        "sendGrid": {
            "from": "Azure Functions <samples@functions.com>"
        },
        "serviceBus": {
          "maxConcurrentCalls": 1,
          "autoRenewTimeout": "00:25:00"
        }
    },
    "healthMonitor": {
        "enabled": true,
        "healthCheckInterval": "00:00:10",
        "healthCheckWindow": "00:02:00",
        "healthCheckThreshold": 6,
        "counterThreshold": 0.80
    },
    "id": "9f4ea53c5136457d883d685e57164f08",
    "logging": {
        "fileLoggingMode": "debugOnly",
        "logLevel": {
          "Function.MyFunction": "Information",
          "default": "None"
        },
        "applicationInsights": {
            "sampling": {
              "isEnabled": true,
              "maxTelemetryItemsPerSecond" : 5
            }
        }
    },
    "watchDirectories": [ "Shared", "Test" ]
}

I see: image

Giving me an indication that everything is loaded BUT the children of “extensions”. Ofcourse, I understand that this might be loaded some how but the AF V2 does not behave how I want, not with concurrent queue, nor with autoRenewTimeout.

So I am looking for assistance on how to handle host.json-files with AF V2, especially autoRenewTimeout is what I am looking for. I have read several threads about this being an issue, but I have set a higher value than the lock of my topic/subscription, but yet it does not renew, leading to a lock exception.

Repro steps

Provide the steps required to reproduce the problem

1. Create a AF V1:

I use the following code:

[FunctionName("Function1")]
        public static void Run([ServiceBusTrigger("%CpamTopicName%", "%CpamSubscription%", Connection = "CpamServiceBusConnection")]BrokeredMessage mySbMsg, TraceWriter log)
        {
            log.Info($"C# ServiceBus topic trigger function processed message: {mySbMsg}");

            try
            {
                for (int i = 0; i < 100; i++)
                {
                    Thread.Sleep(3000);
                    log.Info("number of i: " + i.ToString());
                }
                log.Info("Happy days!");
                mySbMsg.Complete();
            }
            catch (Exception e)
            {
                ;
            }
        }

2. Create AF V2 with the following code:

[FunctionName("Function1")]
        public static void Run([ServiceBusTrigger("%CpamTopicName%", "%CpamSubscription%", Connection = "CpamServiceBusConnection")]string mySbMsg, ILogger log)
        {
            log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");

            try
            {
                for (int i = 0; i < 100; i++)
                {
                    Thread.Sleep(3000);
                    log.LogInformation("number of i: " + i.ToString());
                }
                log.LogInformation("Happy days!");
            }
            catch (Exception e)
            {
                ;
            }
        }

Expected behavior

In AF V2: Output logs, on a single handled run, incrementing for a long time, as well as not throwing lock exception.

Actual behavior

image

It is processing 3 messages at the same time, indicating that it ignores the “extensions” declared in the host.json-file.

And eventually ends up throwing lock exceptions, due to no renewals: LockException

Known workarounds

I don’t know any, possibly rollbacking to AF V1(?).

Related information

I have researched this issue for a few days, regarding the autoRenewalTimeout and have read several clever responses from sources, especially from @SeanFeldman, regarding this and hopefully he can provide insights here.

A few Related links on issue regarding autoRenewalTimeout: SO regarding expiring lock GitHub issue regarding locks

  • Package version

AF V1: Microsoft.Azure.WebJobs.ServiceBus (2.2.0) Microsoft.NET.Sdk.Functions (1.0.14)

AF V2: Azure Functions Core Tools (2.0.3) Functions Runtime Version (2.0.12115.0) Microsoft.Azure.WebJobs.Extensions.ServiceBus (3.0.0) Microsoft.NET.Sdk.Functions (1.0.22) NETStandardLibrary (2.0.3)

I am desperately looking for someone to shine any insights on this issue, and I will closely follow this issue and answer any questions anyone might have.

Thanks, L

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
luddskunkcommented, Sep 29, 2018

CASE CLOSED! Hi again @paulbatum,

I can now update with the information you gave me, I researched the documentation and found the MessageHandlerOptions to have an updated name for the autoRenewTimeout as well. I tried using that and voilá, it worked!

For anyone running into the same issue the host.json file for AF V2 should be maxAutoRenewDuration instead of autoRenewTimeout.

See example file below:

{
  "version": "2.0",
  "extensions": {
    "serviceBus": {
      "messageHandlerOptions": {
        "maxConcurrentCalls": 1,
        "maxAutoRenewDuration": "00:55:00"
      }
    }
  }
}

Thanks a lot for the assistance and efforts put into this 😃 Closing thread!

1reaction
paulbatumcommented, Sep 28, 2018

So it looks like our documentation needs to be updated. Try this:

{
  "version": "2.0",
  "extensions": {
    "serviceBus": {
      "messageHandlerOptions": {
        "maxConcurrentCalls": 1,
        "prefetchCount": 10,
        "autoRenewTimeout": "00:25:00"
      }
    }
  }
}

(yes, WellKnownHostJsonProperties needs to be updated but that is only impacting logging)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Function Setting autoRenewTimeout in host json file ...
1 Answer. I think you have configured host. json using V1 Function reference. For V2 and later, the config has changed.
Read more >
host.json reference for Azure Functions 1.x
Reference documentation for the Azure Functions host.json file with the v1 runtime.
Read more >
Azure function running multiple times for the same service bus ...
Fortunately, Azure Functions can automatically renew the lock for you. In the host.json file there is an autoRenewTimeout setting that specifies for how...
Read more >
Resolving Error in Azure Function with Extension Bundle
Solution: “Extension Bundles” can add a pre-defined compatible set of binding extensions to the function app. Extension bundles are always versioned. · Step1:....
Read more >
Why won't you load my configuration Azure Functions?
I wanted the configuration to be structured so I added it after the "Values" section in the local.settings.json file and ran the application....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found