Deploy AI Image Generation (ComfyUI & Stable Diffusion) on Serverless Function Compute
This guide explains how to quickly deploy popular AI image‑generation models such as ComfyUI and Stable Diffusion WebUI on Alibaba Cloud Function Compute, covering architecture, step‑by‑step deployment, custom workflow creation, model management with NAS, and best‑practice tips for cost and performance.
Solution Overview
The article presents two serverless solutions for AI‑generated images: one using ComfyUI and another using Stable Diffusion WebUI. Both are deployed on Alibaba Cloud Function Compute with NAS storage and a VPC network, offering pay‑as‑you‑go pricing, elastic scaling, and rapid delivery.
Architecture
Function Compute – provides the application runtime for the AI model.
NAS file storage – stores pretrained model files and generated images.
VPC – connects Function Compute to the NAS securely.
Deploying ComfyUI
Open the Function Compute application template, select the East China 1 region, choose the built‑in “clay style” model, keep other settings default, and click Create Application . Model download may take about 15 minutes.
If the role lacks permissions, click Go to Authorization and grant the required rights.
Read the billing notice, check the acknowledgment box, and click Agree and Continue to start deployment.
When deployment finishes, open the domain link shown in the Environment Details page to access the ComfyUI web UI.
Important: Protect the domain to avoid unexpected charges; the provided *.devsapp.net domain is temporary and should be replaced with a custom domain for production use.
First access may show “cannot access this site”; wait about 10 seconds for the cold‑start. Subsequent accesses are fast.
Use the Queue Prompt button to generate the first image; the initial generation can take 30 seconds because the model loads into memory. Monitor the Queue Size indicator to track progress.
Custom prompts can be entered. Example positive prompt: Spring, flowers, willows, little birds, distant green mountains, a boy climbing the mountains, smiles, picture highlight, rich details . Example negative prompt: loli, nsfw, logo, test, badhandv4, EasyNegative, mutated hands and fingers, poorly drawn face, extra limb, missing limb, disconnected limbs, malformed hands, ugly .
Advanced: Custom Clay‑Style Filter
Download the provided workflow.json , open ComfyUI, click Load , and import the workflow file. Upload a source image (portrait recommended) via the Load Image dialog, then run the workflow to produce a clay‑style output.
Advanced: Model Management and NAS Integration
In the Function Compute console, bind a NAS file system, configure the VPC, switch, and security group (auto‑configuration creates these resources automatically; manual configuration lets you select existing ones). Mount the NAS at /mnt/auto for model storage.
Use the Initialize Model Management wizard to create a model library, upload LoRA or other custom models, and manage them through the Model Management UI. Uploaded files appear in the corresponding directory.
Function Compute also provides a built‑in model repository (hosted on OSS). Download models from the repository, they are stored in the NAS, and appear in the Stable Diffusion model list after a refresh.
Deploying Stable Diffusion WebUI
Open the Function Compute application template, select East China 1, choose an anime‑style model, keep defaults, and click Create Application . Model download may take about 15 minutes.
If role permissions are insufficient, click Go to Authorization and grant the needed rights.
Accept the billing items, check the acknowledgment box, and click Agree and Continue to deploy.
After deployment, open the domain link in Environment Details to reach the Stable Diffusion WebUI.
First access may require a 30‑second wait for cold‑start. If an error “Reserve resource exceed limit” appears, switch to a different region.
Enter prompts (positive and negative) and adjust parameters such as sampling steps, sampler, high‑resolution fix, and seed to generate images that meet your requirements.
Advanced: Custom Model Library for Stable Diffusion
Create a NAS‑backed model library, upload custom model weights (e.g., from ModelScope), and mount the library at /mnt/auto. After uploading, refresh the model list; the new model becomes selectable for generation.
References
Configuration of custom domains, provisioned instances, and NAS storage.
Links to the workflow JSON file, ComfyUI examples, Function Compute console, NAS console, pricing overview, ModelScope, and other relevant documentation.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Alibaba Cloud Native
We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
