Azure / Azure/azure-functions-nodejs-library

How to check the status of a Function

Open
#299 0 comments 0 reactions 0 assignees View on GitHub
area:nodejs-functions
Dominant language
TypeScript
Stars
70
Forks
35
Avg merge
4d 18h
Merged PRs (30d)
6

Description

I have a function app using the [`@azure/functions` npm package](https://www.npmjs.com/package/@azure/functions) version `4.5.1`, with the following triggers defined:
```typescript
app.http('info', {
methods: ['GET'],
authLevel: 'anonymous',
handler: ,
route: 'info',
});

app.cosmosDB('consumer', {
connection: 'ConsumerConnection',
databaseName: ,
containerName: ,
leaseContainerName: ,
leaseContainerPrefix: ,
handler: ,
});
```

If I omit the `ConsumerConnection` environment variable and run the app, the function still works (e.g., the HTTP endpoints respond) even if the consumer trigger is not properly configured.
When running locally and removing `ConsumerConnection` from the `local.settings.json file`, the function still works but logs this message:
```
Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.consumer'. Microsoft.Azure.WebJobs.Extensions.CosmosDB:
Cannot create container information for in database with lease in database :
Cosmos DB connection configuration 'ConsumerConnection' does not exist. Make sure that it is a defined App Setting.
Microsoft.Azure.WebJobs.Extensions.CosmosDB: Cosmos DB connection configuration 'ConsumerConnection' does not exist.
Make sure that it is a defined App Setting.
```

My goal is to return a `500` error on the `/info` endpoint if there are issues (like with the `cosmosDB` trigger). Is there a method within the `nodejs-sdk` that exposes the status of a function?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.