General questions about Cloud Functions
Can I get logs of my operations in Yandex Cloud?
Yes, you can request information about operations with your resources from Yandex Cloud logs. Do it by contacting support
How do I upload a ZIP archive with source code to update a serverless function via CLI?
To create a function version from a ZIP file, run this command:
yc serverless function version create --source-path
For more details on uploading code, see this guide.
How large can a source code archive be when uploading to Cloud Functions?
You can upload a file up to 3.5 MB directly. To upload larger files, use Yandex Object Storage. For more information, see this guide.
I am not the cloud owner, but I was granted access. What permissions/roles do I need to publish a function?
To manage function access, you need the admin or resource-manager.clouds.owner role. For more information, see this guide.
How do I access an environment variable in a Node.js function?
To access environment variables, use the process.env global variable. For more information, see this guide
Which Python modules can I use when working with Cloud Functions? How do I add new modules?
You can upload modules in a ZIP archive up to 3.5 MB. To upload larger files, use Object Storage. For more information, see this guide.
Calling Cloud Functions for Alice skills is free. If I call another of my Cloud Functions from a skill function, will that also be free?
Such calls will be subject to fees according to Cloud Functions pricing policy.
I want to increase my quotas. How do I determine appropriate values for them?
For more on which quotas to increase and to what extent, see Relationship between quotas.
Why does an API request return the Illegal duration format error?
If your API request body contains parameters in type.googleapis.com/google.protobuf.Duration format, you may get the following error:
Illegal duration format; duration must end with 's' for type type.googleapis.com/google.protobuf.Duration
When using this format, make sure to append s to duration values.
For example:
{
"timeout": "120s"
}
How do I connect to a managed database from a function?
By default, Cloud Functions run in isolated IPv4 networks with the NAT gateway enabled.
To connect to a cluster, specify the ID of the cloud network containing the cluster in the function properties. The function will then have access to the internet and user resources in the specified network, including virtual machines. For more on how to connect a function to a cloud network, see Networking in Cloud Functions.
You can also connect to a database over the internet. Do it by enabling public access to the cluster and setting up an encrypted connection, which is a requirement for access to a database over the internet as per PCI DSS. For an example of connecting to a Managed Service for MySQL® cluster, see Pre-configuring a MySQL® cluster connection.
Can I assign a static IP address to a function?
No, you cannot assign a static IP address to a function in Cloud Functions. The function can run on resources with different IP addresses.
Alternatively, create a Yandex Compute Cloud virtual machine, assign a static public IP address to it, install the target programming language runtime, and run the code on that VM.
Note
You can also use an API gateway to call the function via a custom domain.
Why do I get a CORS error when trying to access the SpeechKit, Vision OCR, or Translate API?
When calling an API from the web application frontend, you may get the following error:
Access to XMLHttpRequest at '<https://vision.api.cloud.yandex.net/vision/v1/batchAnalyze>'
from origin '...' has been blocked by CORS policy: Response to preflight request doesn't
pass access control check: No 'Access-Control-Allow-Origin'
The web application frontend cannot access the APIs of these services directly. AI services do not support cross-domain requests because their APIs do not respond to the OPTIONS requests.
To send requests to APIs, create a function in Cloud Functions and add a handler that will forward requests to SpeechKit, Vision OCR, or Translate.
Why do I get an No node can serve the request: Concurrent requests exceedederror?
When calling a function, the code is not run and the following message gets logged:
429 Message: No node can serve the request: Concurrent requests exceeded
The error occurs when you exceed one or more of the following quotas:
- Number of concurrent operations on all functions and their versions per cloud.
- Number of concurrent operations on a single function and its versions.
- Number of concurrent calls for all functions per availability zone.
Check your current quota consumption
Why do I see an HTTP 499 error in the function logs?
Your Cloud Functions function may log the following message: Error: Code 499 Message: request cancelled.
This error means that the client terminated the connection before the function finished processing the request. For example, if the code takes 10 seconds to be executed, but the client spends only 5 seconds to wait for the response, the client will close the connection after 5 seconds and log an HTTP 499 error.
To fix this error:
- Increase the client-side response timeout.
- If you cannot change the client-side timeout, break the long job down into several functions started by timer.
If the error persists, add logging to the code and analyze the logs:
Why do I get an No node can serve the request: Too many rescheduleserror?
When calling a function, the code is not run and the following message gets logged:
Code: 429 Message: No node can serve the request: Too many reschedules
The error may occur if a function fails to respond to an HTTP request and terminates. The request is scheduled for a retry, but subsequent attempts fail again causing the call to loop.
To fix the error, bring the function code in line with the runtime requirements.
How do I add an intermediate CA certificate to a function if TLS verification fails with the unable to get local issuer certificate error?
The certificate verify failed: unable to get local issuer certificate error usually means that the server the function connects to returns only the end-entity certificate, without the intermediate one. The root certificate that ultimately signs the certificate chain may be available in the system trust store, but the client cannot build the chain to the root without the intermediate certificate. This may happen when a new CA reissues the certificate but the server still uses the old intermediate certificate, or when the configuration specifies cert.pem instead of fullchain.pem.
Here’s what you can do:
-
If it is your server, configure it to return the full certificate chain (
fullchain.pem). With that done, the verification will succeed without any changes to the function code. -
If it is a third-party server, add an intermediate certificate on the function side. Do it by adding the intermediate certificate file to the function code and providing it to the HTTP client together with the system certificate bundle. Path to the system certificate bundle in the runtime:
/etc/ssl/certs/ca-certificates.crt.Examples for Python:
-
requests: Merge the system bundle (certifi.where()) and your certificate into a single file and provide it in theverify="/path/to/bundle.crt"parameter. Alternatively, set theREQUESTS_CA_BUNDLEenvironment variable for the function version. -
httpx:import httpx client = httpx.Client(verify="/path/to/bundle.crt") -
aiohttpor standardsslmodule:import ssl ctx = ssl.create_default_context(cafile="/etc/ssl/certs/ca-certificates.crt") ctx.load_verify_locations("/path/to/intermediate.crt")
Use a similar approach for other programming languages: provide the path to the additional certificate via the HTTP client or TLS context parameters and extend the system bundle instead of replacing it.
-
Please note:
- Do not provide your certificate in the
verifyparameter without first gluing it together with the system bundle; otherwise, it will disrupt trust verification for all other hosts. - You cannot write the certificate directly into
/etc/ssl/certs/ca-certificates.crtfile inside the function. Connect the certificate via the client parameters as shown above.