Create a function
Cognite Functions isn't enabled by default. Contact firstname.lastname@example.org to enable it for your CDF project.
Before you deploy a function, you must set up GitHub and GitLab.
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.
Add all the required packages for your function to the
requirements.txtfile. Cognite Functions uses this file to install the necessary packages to run your function.
Make sure to add the air-sdk library to the requirements file for every project and function you create.
You must also add the packages above to the Poetry environment.
Navigate to the repoconfig.yaml file in the root folder. Under the project properties tab, make sure to add a mapping value as follows:
PROJECT_NAME: [PROJECT_URL, "PROJECT_NAME_API_KEY"].
ProjectFunctionMap, write the name of the function that needs to be deployed and the project you wish to deploy to.
To test, use the test handler under the test folder in your
If you don't want to deploy the function, add the folder name to the
Create a function called handle under the
handler.pyin 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.
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.