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.
Functions can be created and deployed in different ways to meet your unique development habits. You can automatically deploy Appwrite Functions from source control, build your own deployment pipelines using the Appwrite CLI, or upload code files manually. Here's everything you need to know to deploy your first Appwrite Function.
Git
The recommended way to manage your Appwrite Function deployments is to use a version control system, like Git. This offers simple versioning and collaboration that will easily fit into the rest of your development workflow.


Create function
Before deploying your function with Git, create a new function attached to your Git repo.
Navigate to Functions from the side bar of the Appwrite Console.
Click Create function.
When asked to Choose your source, under Connect Git repository, select your provider.
Search for the Git repository that holds your function and click connect.
Select a production branch. New commits pushed to the production branch will be automatically activated. Commits to any other branch will still be deployed, but not be activated.
Input the root directory of the function inside the repository.
If you don't want deploy comments to be made on your pull requests or commits, select Silent mode.
Name your function, select a runtime that matches your function, and enter entrypoint.
If you have build steps, like installing dependencies, input the commands into the Build settings heading's Command field. For example, npm install && npm build.
Finally, configure the execute permissions of the function.
Deploy
Using Git, checkout the branch you configured as the production branch when creating the Appwrite Function.
Create a new commit.
Push your new commit.
A new deployment will be automatically created, built and activated.
CLI
CLI setup
Before you can deploy with the Appwrite CLI, make sure you've installed and initialized the CLI.
To deploy with the Appwrite CLI, your function must be added to appwrite.json. Use the appwrite init function method to create a starter function, then paste in your function code.
appwrite init function
Edit the generated code, add dependencies, and deploy the function using the following command:
appwrite deploy function
Overwrite warning
If you made changes in the Appwrite Console that are different from your appwrite.json, using the CLI deploy command will overwrite your console changes. Update your appwrite.json manually before deploying.
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.
Domains
Each deployed function can have its own domain. By default, one is generated for each of your functions.
To find or add a domain:
Navigate to the Appwrite Console's Functions page.
Navigate to the Domains tab.
Click on Create domain.
Input your domain and click Next.
Copy the CNAME record and add it to your domain registrar.
Click Go to console and wait for verification and certificate generation.
DNS records can take up to 48 hours to propagate.
Debugging Build
After deploying a function, you can find the status and build logs in the Appwrite Console.
Navigate to Functions.
Open the function you wish to inspect.
Under the Deployments tab, find the status of the current and previous deployments.
Access build logs by clicking the Build logs button.
Redeploy Builds
After updating the configuration, redeploy your function for changes to take effect. You can also redeploy to retry failed builds.
Navigate to Functions.
Open the function you wish to inspect.
Under the Deployments tab, find the status of the current active deployment.
Redeploy by clicking the triple-dots beside an execution, and hitting the Redeploy button.
Redeployment behavior varies depending on how the initial deployment was created.