Azure-functions-host: Can't get the function ID

Created on 19 Jul 2016  路  8Comments  路  Source: Azure/azure-functions-host

Currently, the function app can't get function ID. I would like to get function ID. Example, If I write any files using the function ID as follows:
xxxx_<function id>.log

If I can use function ID in file name, that association will be easy to function log table data.

Most helpful comment

You can access the invocation ID in a Node function via context.bindingData.InvocationId. In a CSharp function, you can access it by adding an ExecutionContext parameter as follows:

public static void Run(string input, ExecutionContext executionContext, TraceWriter log)
{
    log.Info($"InvocationId: {executionContext.InvocationId}");
}

All 8 comments

Could you be more specific? Function ID is the function name.

Do you mean execution ID?

@christopheranderson Yes, It means execution ID.

You can access the invocation ID in a Node function via context.bindingData.InvocationId. In a CSharp function, you can access it by adding an ExecutionContext parameter as follows:

public static void Run(string input, ExecutionContext executionContext, TraceWriter log)
{
    log.Info($"InvocationId: {executionContext.InvocationId}");
}

@mathewc Great! Thanks a lot. :)

@mathewc Is supported ExecutionContext in csx, just now? I got error as follows:
Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.HttpTriggerCSharp1'. mscorlib: An item with the same key has already been added.

  • Runtime version: Latest (~0.4)
  • However JavaScript is success (context.bindingData.invocationId)

Change the parameter name from "context" to something else, e.g. "executionContext" and it works. The bug is that we have an internal system parameter named "context" already. We'll address that issue.

@mathewc works fine! Thanks.

Is there any way to get the id without referencing any azure packages? I'd love to have Run(string id, MyModel data, CancellationToken token)

Was this page helpful?
0 / 5 - 0 ratings