
I have deployed some functions from my local appwrite instance to server appwrite instance. But, when I deployed the environment variables of the functions I created on my local machine weren't moved to the server.
Now, what should I do? Manually add these variables again through console? Or, do we have any config or env file where I can add those and upload to server?
I have multiple environment variables for each functions. So, it's really annoying to write the variables every time I deploy to the server or reconfigure the server.

Hey there 👋 When you deploy a function (appwrite deploy function
), it does not read your .env
file.
Deployment of a function does not touch your variables, by default.
To make deployment update your variables, you can specify variables
key in definition of your function in appwrite.json
. Keep in mind, this will overwrite ever variable currently configured on the function, and only apply those in appwrite.json.
Keep in mind this will result in you storing secrets inside appwrite.json
. So make sure to NOT push this to your version control such as git, otherwise you are creating security vulnerabilities.

Can you share an example appwrite.json? And, do you have this info in your documentation?

I dont have any example project with variables in appwrite json :/ Tho it would look something like this:
{
"projectId": "almostGist",
"projectName": "Almost Gist",
"collections": [],
"functions": [
{
"$id": "toggleReaction",
"name": "toggleReaction",
"runtime": "node-16.0",
"path": "functions/toggleReaction",
"entrypoint": "src/index.js",
"ignore": [
"node_modules",
".npm"
],
"execute": [
"users"
],
"events": [],
"schedule": "",
"timeout": 15,
"variables": {
"MAX_ALLOWED_REACTIONS": "5"
}
}
]
}
Docs: https://appwrite.io/docs/command-line-deployment#function-options

Great, thanks

Hi @Meldiron , I tried your method but it's not working unfortunately. And, when I'm deploying the function on server, the appwrite.json on the server is not updating. Am I missing something here?

@shofol this will help you: https://github.com/rafagazani/church_appwrite_example

This repository aims to facilitate the deployment of an appwrite project. In it you will find a way to send collections, attributes, index and functions in an automated way.

the cool thing is that if you have more than one server, just change the credentials in the env.py file. It was very annoying to run appwrite logout login when you have more than one server

What Appwrite CLI version do you have? appwrite --version

1.2.1. I tied again, now the variables are copied but appwrite.json on the server is not updated yet. Is this an expected behavior?

appwrite.json should live in your web app folder. On server, there is no need for appwrite.json.

Ok
Recommended threads
- Google login error: {"message":"Invalid ...
hi, im trying to use google login with account.createOAuth2Session( 'google', 'profevardilla.pages.dev', 'profevardilla.pages.dev'...
- Create owner team member with Server fun...
I understand that when creating a team with a function, the user that made the request will not be the owner so I think I have to add the user that did the requ...
- Schedule a function job with timezone
I am aware that cron schedule will work on UTC timezone. I would like to run my function at a particular time everyday in new york time. If I use UTC, it will m...
