Skip to content

How to check the status of a Function #299

Open
@kin0992

Description

@kin0992

I have a function app using the @azure/functions npm package version 4.5.1, with the following triggers defined:

app.http('info', {
  methods: ['GET'],
  authLevel: 'anonymous',
  handler: <info-handler-function>,
  route: 'info',
});

app.cosmosDB('consumer', {
  connection: 'ConsumerConnection',
  databaseName: <database-name>,
  containerName: <container-name>,
  leaseContainerName: <lease-container-name>,
  leaseContainerPrefix: <lease-container-prefix>,
  handler: <consumer-handler-function>,
});

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 <container-name> in database <database-name> with lease <lease-container-name> in database <database-name> : 
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions