Built-in variables

There are several environment variables available to all Binaris functions out-of-the-box.

BINARIS_ACCOUNT_ID:

The Binaris Account ID which the current Function belongs to.

Example: 3952451808

BN_FUNCTION

The name of the current Binaris Function. Same as the function name defined in binaris.yml.

Example: hello

BN_RUNTIME

The runtime executing the code of the current Binaris Function. Same as the runtime attribute defined in binaris.yml.

Example: node8

BN_FILE

The file which contains the code of the current Binaris Function. Same as the file attribute defined in binaris.yml. Example: function.js

BN_ENTRYPOINT

Name of the function that’s the entry point to the current Binaris Function. Same as the entrypoint attribute defined in binaris.yml.

Example: handler

BINARIS_INVOKE_ENDPOINT

The base address for function invocations.

Example: run-sandbox.binaris.com

BINARIS_DEPLOY_ENDPOINT

Deployment base address.

Example: api-sandbox.binaris.com

BINARIS_LOG_ENDPOINT

Log endpoint base address.

Example: log-sandbox.binaris.com

Usage examples

The following snippets build a URL of the currently running function (e.g. https://run-sandbox.binaris.com/v2/run/3952451808/hello) from the built-in environment variables.

Node.js

const {
  BINARIS_ACCOUNT_ID,
  BN_FUNCTION,
  BINARIS_INVOKE_ENDPOINT
} = process.env;

const url = `https://${BINARIS_INVOKE_ENDPOINT}/v2/run/${BINARIS_ACCOUNT_ID}/${BN_FUNCTION}`;

Python

import os

binaris_account_id = os.environ['BINARIS_ACCOUNT_ID']
bn_function = os.environ['BN_FUNCTION']
binaris_invoke_endpoint = os.environ['BINARIS_INVOKE_ENDPOINT']

url = 'https://{}/v2/run/{}/{}'.format(binaris_invoke_endpoint, binaris_account_id, bn_function)