I am new in appwrite cloud function
This is the boilerplate code when we create new python function
TypeScript
from appwrite.client import Client
# You can remove imports of services you don't use
from appwrite.services.account import Account
from appwrite.services.avatars import Avatars
from appwrite.services.databases import Databases
from appwrite.services.functions import Functions
from appwrite.services.health import Health
from appwrite.services.locale import Locale
from appwrite.services.storage import Storage
from appwrite.services.teams import Teams
from appwrite.services.users import Users
def main(req, res):
client = Client()
# You can remove services you don't use
account = Account(client)
avatars = Avatars(client)
database = Databases(client)
functions = Functions(client)
health = Health(client)
locale = Locale(client)
storage = Storage(client)
teams = Teams(client)
users = Users(client)
if not req.variables.get('APPWRITE_FUNCTION_ENDPOINT') or not req.variables.get('APPWRITE_FUNCTION_API_KEY'):
print('Environment variables are not set. Function cannot use Appwrite SDK.')
else:
(
client
.set_endpoint(req.variables.get('APPWRITE_FUNCTION_ENDPOINT', None))
.set_project(req.variables.get('APPWRITE_FUNCTION_PROJECT_ID', None))
.set_key(req.variables.get('APPWRITE_FUNCTION_API_KEY', None))
.set_self_signed(True)
)
return res.json({
"areDevelopersAwesome": True,
})
My question here is that:
- Where I can locate the [APPWRITE_FUNCTION_ENDPOINT]?
- Do I need to create APPWRITE FUNCTION API KEY environment? and If yes, how can I create api key then?
TL;DR
1. The [APPWRITE_FUNCTION_ENDPOINT] can be located in the environment variables. Make sure it is set correctly.
2. Yes, you need to create the APPWRITE FUNCTION API KEY environment variable. To create an API key, you can follow these steps:
- Go to the Appwrite dashboard.
- Navigate to the project where you want to create the API key.
- Click on the "API Keys" tab.
- Click on the "Create Key" button.
- Give a name to your API key and choose the relevant permissions.
- Click on the "Create" button.
- Copy theRecommended threads
- Appwrite-injected variables are not avai...
I am using rust-1.83 as a runtime and try to access APPWRITE_FUNCTION_API_ENDPOINT or APPWRITE_FUNCTION_API_KEY during runtime. Both are not set during my execu...
- Functions in cloud console not works
please advise as all of my runing functions on Appwrite console was working before , but now it give this error [Invalid `headers` param: Value must be a valid...
- [SOLVED] Production down - createExecuti...
Hey, Since 1.9.6 rollout in fra (~17:00 UTC, 14 Aug), POST /v1/functions/{functionId}/executions returns a 400 whenever the body includes an empty headers ob...