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
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...