If your Serverless App Engine (SAE) application and Container Registry (ACR) instance are in different Alibaba Cloud accounts, first ensure network connectivity. Then, configure authorization to access the ACR instance. Finally, provide the image repository address to deploy the application.
Prerequisites
Ensure network connectivity for SAE and ACR
You must either establish cross-VPC connectivity or enable a public NAT gateway for your application's Virtual Private Cloud (VPC). For ACR Enterprise Edition instances, you must also add the CIDR block of the SAE application's VPC or the Elastic IP Address (EIP) bound to the NAT gateway to the ACR instance's whitelist.
Configure ACR access authorization
You can use either Static Username and Password or a RAM Role.
Static username and password
Create a Secret to store the username and password for the image repository. On the Namespace page, select a region, click the target namespace, choose Secret in the left-side navigation pane, and then click Create.
-
Set Type to Private Image Repository Logon Key.
-
In the Image Repository Address field, enter the public domain of the ACR instance. For example,
registry.cn-xx.aliyuncs.comfor Container Registry Personal Edition orxx-registry.cn-xx.cr.aliyuncs.comfor ACR Enterprise Edition. Enter the Username and Password to log on to the image repository.
RAM role
SAE can pull images from an ACR instance in another account by assuming a RAM role. For example, an application in Account A can assume a RAM role in Account B to pull images from an ACR instance owned by Account B.
-
Create a RAM role: Use Account B to create a RAM role for Account A. For more information, see Create a RAM role for a trusted Alibaba Cloud account.
-
Configure an access policy: Create a custom policy or modify a custom policy to include the following statements to allow operations on private images.
{ "Version": "1", "Statement": [ { "Effect": "Allow", "Action": [ "cr:GetAuthorizationToken", "cr:ListInstanceEndpoint", "cr:PullRepository", "cr:GetRepository", "cr:ListRepositoryTag" ], "Resource": "*" } ] } -
Grant permissions to the RAM role: Grant the access policy from Step 2 to the RAM role from Step 1. For more information, see Manage RAM role permissions.
-
Modify the trusted entity of the RAM role: Change the trusted entity of the RAM role from Step 1 to the SAE service account by modifying the trust policy. For more information, see Modify the trust policy of a RAM role.
Before
After
{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "RAM": [ "acs:ram::123456789012****:root" ] } } ], "Version": "1" }This RAM role can be assumed by any authorized RAM user or RAM role under the Alibaba Cloud account (AccountID=123456789012****).
{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": [ "123456789012****@sae.aliyuncs.com" ] } } ], "Version": "1" }This RAM role can only be assumed by the SAE service account (123456789012****@sae.aliyuncs.com) for the Alibaba Cloud account (AccountID=123456789012****).
NoteIn this example,
Servicerefers to the service that pulls the image. -
Copy the ARN: On the Basic Information page of the RAM role, copy the ARN. You will need this value for the acrAssumeRoleArn field when deploying the application.
Procedure
-
On the SAE Application List page, select a region and namespace, then click Create Application.
-
Select an application edition.
ImportantLightweight Edition and Professional Edition are invite-only. If you are not in the beta, your application defaults to Standard Edition and no edition selection is required.
-
Lightweight Edition: Minimum feature set. Does not support Application Monitoring or Microservices Governance.
-
Standard Edition: Includes Basic Application Monitoring. Advanced Application Monitoring and Microservices Governance must be enabled and purchased separately.
-
Professional Edition: Includes Advanced Application Monitoring and Microservices Governance — no separate enablement or purchase required.
-
-
On the Create Application page, specify an Application Name and configure the following parameters.
-
Select a namespace type. Namespaces isolate resources across environments and cannot be changed after creation.
-
System Created: Uses the default namespace, vSwitch, and security group automatically created in the current region.
-
Existing Namespace: Select a namespace, vSwitch, and security group that you created in advance.
-
-
Set Application Deployment Method to Select Image Deployment, and then click Specify Image on the right. On the Private Images of Other Alibaba Cloud Account tab, configure the following parameters.
-
Select your ACR edition, and then choose an authorization method. For ACR Enterprise Edition, you must also enter the Enterprise Edition Instance ID.
-
Static Username and Password: Select the Secret for Username and Password of Image Repository that you created earlier.
-
RAM Role: Enter the acrAssumeRoleArn that you copied earlier.
-
-
Enter the Complete Image Repository Address in the format
<image-repository-address>:<image-tag>. For example:registry.cn-xx.aliyuncs.com/xx/xx:1.0for Container Registry Personal Edition, orxx-registry.cn-xx.cr.aliyuncs.com/xx/xx:1.0for ACR Enterprise Edition.Note: Use the public or private image repository address that corresponds to your network configuration. -
For ACR Enterprise Edition, you can enable image acceleration to speed up application startup.
-
-
In the Capacity Settings section, configure Resource Type, Single Instance Specification, and Number of Instances.
-
-
(Optional) Click Next: Advanced Settings to configure additional features.
-
Click One-Click Create Application or Create Application.
-
Creation takes 1–2 minutes. View the change records to verify deployment status. If deployment fails, no instances are created — check the error in Change Details.
-
View created applications on the page. To modify configuration, open the application details page and click Deploy Application or Modify Application Configurations. The application restarts to apply changes — do this during off-peak hours.
-
You can log on to an application instance by using Webshell to run console commands.
-
After creation, manually adjust the number of instances and the instance specification, or configure an auto scaling policy. Enable idle mode to reduce costs.
-