I have a typical NodeJS Azure Function App with a Function inside, generated by the func standard CLI in Typescript.
The function has a default structure:
const httpTrigger: AzureFunction = async function (context: Context,
req: HttpRequest): Promise<void> {
...
const mySecret = await secretClient.getSecret(mySecretName);
...
}
Now, every call of a handler triggers a call to KeyVault that looks very slow and red on my Application Map. Therefore I am looking into moving secret readout to the section before the trigger. It would allow, in my understanding, that if function is warm, then trigger will spend no time li getting secrets again and again. (I stress this is my guess but not a hard fact as I am not entirely familiar with Function App lifecycle).
How can I correctly implement logic "do this async initialization of a Function and allow calling trigger only after it is fully completed"?