Tommy Aria Pradana
Tommy Aria Pradana

Reputation: 624

How to get Azure Functions's framework generated request id?

Every time i am debugging my Azure Functions (locally) then invoking a function, the CLI (func.exe) always shows requestId as one of the incoming request's parameters which i am highly sure it is not from my side that generate it.

screenshot from CLI

My question is, is it possible to extract the value of requestId value from our code and how ? is this feature only specific for development/local debugging only ? since i can't find any documentation, article nor blog regarding this.

thank you

Upvotes: 2

Views: 1724

Answers (1)

Kane
Kane

Reputation: 16802

I believe you will find the request information in the HttpContext

req.HttpContext.Items["MS_AzureFunctionsRequestID"]

c# code example assuming you have the following signature

public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log) {}

Upvotes: 2

Related Questions