Invoking a container asynchronously
Note
This feature is at the Preview stage.
Setting up asynchronous invocation
-
In the management console
, select the folder with your container. -
Go to Serverless Containers.
-
Select the container whose revision you want to create.
-
Navigate to the Editor tab.
-
Under Asynchronous invocation:
- Enable asynchronous invocation.
- Specify a service account with the
serverless-containers.containerInvokerrole for asynchronous invocations.
-
Click Create revision.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
To set up asynchronous invocation, run the following command:
yc serverless container revision deploy \
--container-name <container_name> \
--image <Docker_image_URL> \
--service-account-id <service_account_ID> \
--async-service-account-id <ID_of_service_account_for_asynchronous_invocations>
Where:
--service-account-id: ID of the service account with theserverless-containers.editorrole or higher.--async-service-account-id: ID of the service account with theserverless-containers.containerInvokerrole for asynchronous invocations.
Result:
done (6s)
id: bba1r76l8f73********
container_id: bbado1g2mtqj********
created_at: "2025-09-08T12:03:32.797Z"
image:
image_url: cr.yandex/crpmfvcgnl26********/ubuntu:hello
image_digest: sha256:96ab2d89a82fcfc63e24b9ef26de8b3b11ed1043cec41d4359a8de8b********
resources:
memory: "134217728"
cores: "1"
core_fraction: "100"
execution_timeout: 3s
concurrency: "1"
service_account_id: ajelprpohp7r********
status: ACTIVE
log_options:
folder_id: b1g681qpemb4********
runtime:
http: {}
async_invocation_config:
service_account_id: ajeaim70pe1u********
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To set up asynchronous invocation:
-
Open the Terraform configuration file and add the
async_invocationsection to the container description:resource "yandex_serverless_container" "test-container" { name = "<container_name>" memory = "<RAM_size>" execution_timeout = "<execution_timeout>" service_account_id = "<service_account_ID>" image { url = <container_image_path> } async_invocation { service_account_id = "<service_account_ID>" } }Where:
-
async_invocation: Asynchronous invocation parameters:service_account_id: Service account with theserverless-containers.containerInvokerrole.
For more information about
yandex_serverless_containerproperties, see the relevant provider documentation. -
-
Apply the changes:
-
In the terminal, navigate to the configuration file directory.
-
Make sure the configuration is correct using this command:
terraform validateIf the configuration is valid, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
-
Apply the configuration changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
-
You can check the container's update and settings using the management console
yc serverless serverless-container revision get <container_revision_ID>
To configure asynchronous invocation, use the deployRevision REST API method for the Container resource or the ContainerService/DeployRevision gRPC API call.
Invoke the container
When invoking the container over HTTP, specify the X-Ycf-Container-Integration-Type: async header.