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.
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.
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)
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 anExecutionContextparameter as follows: