OpenClaw is an open-source personal AI assistant that runs 24/7 and communicates through Discord, Telegram, WhatsApp, and more. This guide shows you how to deploy it on Azure Container Apps with a single command (azd up), with built-in security features.
π The Quick Version: Create a Discord bot, clone the repo, run
azd up, invite bot to server, start chatting. Total time: ~25 minutes. Total cost: ~$40-60/month.
Why Azure Container Apps over other options?
- β Managed Identity - No credentials in config files
- β Built-in Secrets - API keys never exposed in logs
- β Automatic HTTPS - Free TLS certificates
- β Hyper-V Isolation - Hardware-level container security
- β Compliance Ready - SOC2, ISO, HIPAA certifications
What is OpenClaw?
If you've ever wanted a personal AI assistant that actually does things - not just answers questions - OpenClaw is for you. Created by Peter Steinberger and a growing open-source community, OpenClaw is a personal AI assistant that:
| Capability | Description |
|---|---|
| Runs 24/7 | On your own infrastructure, always available |
| Multi-channel | Telegram, Discord, WhatsApp, Slack, iMessage, and more |
| Persistent memory | Remembers your preferences and context across sessions |
| Task execution | Autonomously clears inboxes, deploys code, manages files |
| Skill learning | Creates reusable "skills" that you teach it |
π‘ Think of it as: A very capable coworker who never sleeps, works and gets better over time.
Why Azure Container Apps?
The original setup guide for OpenClaw uses AWS EC2, but Azure Container Apps offers significant advantages for running a 24/7 AI assistant - especially around security.
The 30-Minute Setup
Prerequisites
Before you start, you'll need:
| Requirement | Link |
|---|---|
| β Azure subscription | Free tier works for testing |
| β Azure CLI | Install here |
| β Azure Developer CLI (azd) | Install here |
| β OpenRouter API Key | openrouter.ai/keys (recommended) |
| β Discord Account | For bot creation |
π‘ Why OpenRouter? OpenRouter provides access to multiple AI models (Claude, GPT-4, Gemini) through a single API. For the simplicity for this demo we are using OpenRouter.
Step 0: Create Discord Bot
β οΈ Important: Do this before running azd up - you'll need the bot token during deployment.
| Step | Action |
|---|---|
| 1 | Go to Discord Developer Portal |
| 2 | Click New Application β Name it (e.g., "OpenClaw-Azure") |
| 3 | Go to Bot β Click Add Bot |
| 4 | Enable Privileged Gateway Intents: Message Content β , Server Members β |
| 5 | Click Reset Token β Copy the bot token (save it securely!) |
| 6 | Go to OAuth2 β URL Generator |
| 7 | Select Scopes: bot, applications.commands |
| 8 | Select Permissions: Send Messages, Read Message History, View Channels |
| 9 | Copy the generated OAuth2 URL (you'll need this to invite the bot) |
Get Your Discord User ID:
| Step | Action |
|---|---|
| 1 | In Discord: Settings β Advanced β Enable Developer Mode |
| 2 | Right-click your username β Copy User ID |
Security Note: The Discord User ID is used for the DM allowlist. Only users in this list can message your bot directly.
Step 1: Clone the Repo
Clone the deployment template:
git clone https://github.com/BandaruDheeraj/moltbot-azure-container-apps
cd moltbot-azure-container-apps
Step 2: Deploy to Azure
Run the initial provisioning:
azd provision
You'll be prompted for:
| Prompt | What to Enter |
|---|---|
| Environment name | OpenClaw-prod |
| Azure subscription | Select from your list |
| Azure location | eastus2 (recommended) |
Note:
azd provisioncreates the Azure infrastructure without deploying the app. We need to build the image first.
This creates:
| Step | What Happens |
|---|---|
| Step 1: | Creates a Resource Group |
| Step 2: | Deploys Azure Container Registry |
| Step 3: | Sets up Azure Storage for persistent data |
| Step 4: | Creates a Container Apps Environment |
| Step 5: | Configures Log Analytics for monitoring |
Build Container Image
β οΈ This must be done before deploying the app. The container image needs to exist in ACR before the Container App can pull it.
# Get your ACR name from the provisioned resources
ACR_NAME=$(az acr list --resource-group rg-OpenClaw-prod --query "[0].name" -o tsv)
# Build the image in Azure Container Registry (no local Docker needed!)
az acr build --registry $ACR_NAME --image "OpenClaw:latest" --file src/OpenClaw/Dockerfile src/OpenClaw/
Understanding this command:
| Part | What It Does |
|---|---|
--registry $ACR_NAME | Build in your Azure Container Registry (in the cloud) |
--image "OpenClaw:latest" | Name the output image OpenClaw:latest (we choose this name) |
--file src/OpenClaw/Dockerfile | Use the Dockerfile from our sample repo |
src/OpenClaw/ | Send this folder as the build context |
π‘ What happens during the build? The Dockerfile in our sample (at
src/OpenClaw/Dockerfile) automatically:
- Starts from a Node.js base image
- Clones the official OpenClaw source code from GitHub
- Installs dependencies with pnpm
- Builds the TypeScript application
- Builds the Control UI
- Adds our custom
entrypoint.shthat generates config from Azure environment variablesYou don't need to download OpenClaw separately - it's pulled fresh from GitHub during the ACR build. The resulting image is stored in your ACR as
OpenClaw:latest.
Configure Credentials
Set your secrets before deploying:
cd moltbot-azure-container-apps
# Set your required secrets
azd env set OPENROUTER_API_KEY "sk-or-v1-your-key-here"
azd env set DISCORD_BOT_TOKEN "your-discord-bot-token"
azd env set DISCORD_ALLOWED_USERS "your-discord-user-id"
Where to get these values:
| Variable | Where to Get It |
|---|---|
OPENROUTER_API_KEY | openrouter.ai/keys |
DISCORD_BOT_TOKEN | Discord Developer Portal β Your App β Bot β Reset Token |
DISCORD_ALLOWED_USERS | Discord β Settings β Advanced β Developer Mode β Right-click your username β Copy User ID |
Optional settings:
# Change the AI model
azd env set OPENCLAW_MODEL "openrouter/anthropic/claude-3.5-sonnet"
# Change the bot's name
azd env set OPENCLAW_PERSONA_NAME "Clawd"
# Add IP restrictions (for security)
azd env set ALLOWED_IP_RANGES "1.2.3.4/32"
# Enable email alerts
azd env set ALERT_EMAIL_ADDRESS "your-email@example.com"
Deploy Application
Now deploy with your configuration:
azd deploy
This deploys OpenClaw to Container Apps with all your secrets configured.
β οΈ Important: If you change any environment variables later, run
azd deployagain to apply them.
Step 3: Invite Bot to Server
β οΈ Critical: Discord requires bots and users to share a server before DMs work!
| Step | Action |
|---|---|
| 1 | Open the OAuth2 URL you copied in Step 0 |
| 2 | Select a server to invite the bot to (or create a new one) |
| 3 | Click Authorize |
Step 4: Start Chatting
| Step | Action |
|---|---|
| 1 | Find your bot in the server's member list (right sidebar) |
| 2 | Right-click the bot β Message to open a DM |
| 3 | Send: Hello! |
| 4 | Wait a few seconds for the response π |
π You're now chatting with your personal AI assistant running 24/7 on Azure!
What You Just Deployed
Here's what's running in your Azure subscription:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Azure Resource Group β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β Azure Container Apps Environment ββ
β β ββ
β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ
β β β π¦ OpenClaw Container App β ββ
β β β β ββ
β β β Gateway β Control plane for sessions and tools β ββ
β β β Control UI β Web dashboard for management β ββ
β β β Channels β Telegram, Discord, WhatsApp connections β ββ
β β β Skills β Extensible automation capabilities β ββ
β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β βββββββββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββ β
β β Container β β πΎ Storage β β π Log Analytics β β
β β Registry β β Account β β β β
β β (stores image) β β (persistent data) β β (logs & metrics) β β
β βββββββββββββββββββββββ βββββββββββββββββββββββ βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Cleaning Up
When you're done experimenting:
azd down --purge
This removes all Azure resources. Your data in Azure Storage will be deleted.
Resources
| Resource | Link |
|---|---|
| OpenClaw Docs | docs.openclaw.bot |
| OpenClaw GitHub | github.com/OpenClaw/OpenClaw |
| OpenClaw Discord | discord.gg/openclaw |
| Azure Container Apps | Documentation |
| Sample Repository | GitHub |
Deploy OpenClaw with a single command:
# Clone the sample repository
git clone https://github.com/BandaruDheeraj/moltbot-azure-container-apps
cd moltbot-azure-container-apps
# Deploy everything with Azure Developer CLI
azd up
Repository: github.com/BandaruDheeraj/moltbot-azure-container-apps
Questions or feedback? Join the OpenClaw Discord or open an issue on the sample repository.