Appwrite Functions are mini-applications in Appwrite with their own endpoints. Each function can have many deployments, which can be thought of as versions of the mini-application.
While we recommend you create deployments through automatic Git deployments, you can also create deployments manually or through the Appwrite CLI.
CLI
You can create functions using the CLI without needing to access the Console.
Before proceeding
Ensure you install the CLI, log in to your Appwrite account, and initialize your Appwrite project.
To deploy your function with the Appwrite CLI, use the appwrite init functions command to create a starter function and paste your code into the generated file and folder.
appwrite init functions
To deploy the generated code, add any dependencies and push the function using the following command:
appwrite push functions
Learn more about the CLI functions commands
Configure CLI deployments
If you need to target a different project, API endpoint, change the path or entry point of your function, or update any of the other configuration options, you can do so by editing the appwrite.json file.
Learn more about appwrite.json
Manual Deployment
You can upload your functions to be deployed using the Appwrite Console. The example below shows a simple Node.js function.
.
├── package.json
└── index.js
First, navigate inside the folder that contains your dependency file. Package your code files into the .tar.gz format:
tar --exclude code.tar.gz -czf code.tar.gz .
Next, navigate to your Appwrite Console and upload the function.
Navigate to the function you want to deploy.
Click Create deployment.
Select the Manual tab.
Input the entry point of your function under Entrypoint. For the example above, it would be index.js.
Upload code.tar.gz.
Select Activate deployment after build.
Click Create.
Debugging
If you updated your function's configuration but the deployment is not working as expected, you may need to first redeploy your function before the changes take effect.
If you notice your function is missing dependencies during build or at runtimes, update it's build settings. Navigate to Functions > your function > Settings > Configuration > Build settings. These commands will be ran before the function is built and can be used to install dependencies.
If you're missing some code files at build time, make sure they are included in the Root directory. Only files in the root directory folder will be copied to the executor.