Skip to main content

Create a function


Cognite AIR and Cognite Functions are not enabled by default. Contact to enable them for your CDF project.

Before you deploy a function, you must set up GitHub and GitLab.

  1. For your function to be deployed correctly to Cognite Functions and the AIR backend, you must edit the configuration file: config.yaml. This file lets you set many options.

  2. Add all the required packages for your function to the requirements.txt file. Cognite Functions uses this file to install the necessary packages to run your function.

  3. Make sure to add the air-sdk library to the requirements file for every project and function you create.

  4. You must also add the packages above to the Poetry environment.

  5. Navigate to the repoconfig.yaml file in the root folder. Under the project properties tab, make sure to add a mapping value as follows:


    Under the ProjectFunctionMap, write the name of the function that needs to be deployed and the project you wish to deploy to.

  6. To test, use the test handler under the test folder in your function_name folder.

  7. If you do not want to deploy the function, add the folder name to the .ignore_models file.

  8. Create a function called handle under the in your functions folder. This handle function behaves as a main() function. Any code there will be run by Cognite Functions when you deploy your function.

  9. When the function is ready, use the GitHub commands add, commit, and push your code to your remote repository. Then open a pull request. Merge the pull request to master, and your function is deployed to Cognite Functions.