Skip to content

About

Deploy OpenClaw to Azure VM and use models on Foundry by 1-click.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

40 Commits

Folders and files

Repository files navigation

azure-openclaw

Deploy OpenClaw on an Azure VM with an AI Foundry backend and keep your runtime helpers versioned in the same repo.

Open in Codespaces [Deploy to Azure]( https://portal.azure.com/#create/Microsoft.Template/uri/ https%3A%2F%2Fraw.githubusercontent.com%2FHaoHoo%2Fazure-openclaw%2Fmain%2Finfra%2Fmain.json ?repository=https%3A%2F%2Fgithub.com%2FHaoHoo%2Fazure-openclaw&path=infra&branch=main )

Overview (English)

  • Infrastructure-first – Two Bicep modules wire up networking, a Linux VM, Azure OpenAI, and AI Foundry. infra/main.bicep exposes the knobs (modelName, openclawPort, dynaIP, scriptsRepoUrl, etc.) and forwards them into the resource module, while infra/resources.bicep injects the cloud-init bootstrap and the Custom Script Extension payload.
  • Setup script workflow – The Custom Script Extension runs scripts/set-openclaw.sh, which clones this repository, copies the complete scripts/ directory into the administrator home, records the environment metadata (including whether dynamic IP is enabled), installs OpenClaw, merges openclaw.json, and wires cron jobs for update-apikey.sh and update-ddns-a.sh.
  • Dynamic DNS ready – When dynamic public IP is enabled, set-openclaw.sh runs set-dync-dns.sh; the helper prompts you to pick a provider (currently Aliyun), saves your credentials/domain/record info under the aliyun section of scripts/update-dns/ddns.json, and rewrites update-ddns-a.sh into an Aliyun-specific updater that re-reads that JSON on every run (including the latest recordId/currentIp) before calling the Aliyun CLI, so removing the provider field is now safe and future providers can share the same driver pattern.
  • Secure metadata refresh – update-apikey.sh sources the generated .azure.env, hits Azure to refresh the OpenAI key, writes the latest metadata to resource.json, and rewrites ~/.openclaw/openclaw.json so OpenClaw always uses the newest endpoint/key.
  • Reusable helpers – Because the scripts directory is replaced wholesale via git clone, you can add new helpers (or new DDNS providers) and publish them in this repo; set-openclaw.sh will pull them down automatically on every deployment.

部署说明(中文)

  • 一键部署 – azd up 或 az deployment group create 会先创建资源组、VM、AI Foundry、OpenAI 账号和模型部署, 再通过 Custom Script 自动运行 scripts/set-openclaw.sh。
  • azd 自动部署标准布局 – 仓库根目录保留 azure.yaml (引用 infra/main.bicep)、infra/、scripts/ 以及 helper, azd/快速部署按钮可以自动检测模板,并从 scripts/set-openclaw.sh 启动安装逻辑。
  • 脚本如何加载 – set-openclaw.sh 会 clone 指定的 scriptsRepoUrl/scriptsRepoRef,把全部 scripts/ 复制到 /home/<admin>/scripts、赋予执行权限,并向 .azure.env、 resource.json、openclaw.json 写入最新的环境参数;同时如果动态 公网 IP 启用时会调用 set-dync-dns.sh。该脚本也会注册 cron 任务让 update-apikey.sh 和 update-ddns-a.sh 在每次重启后执行。
  • 动态域名更新 – 运行 set-dync-dns.sh 后选择 Aliyun DNS, 脚本会安装 Aliyun CLI、让你输入 Access Key ID/Secret、域名、子域名后 获取 RecordId 并把它们以及 currentIp/lastConfigured/lastUpdated 写在 scripts/update-dns/ddns.json 的 aliyun 区块内,之后 update-ddns-a.sh 会被重写为每次读取该区块并用最新值调用 Aliyun CLI (如果 ddns.json 缺失会提示先重跑 set-dns-ali.sh)。后续如果新增 其他 DDNS 服务,只需对应服务重写 update-ddns-a.sh 接口即可。
  • 安全更新流水线 – update-apikey.sh 从 .azure.env 中读取凭据后 调用 az cognitiveservices account keys list、更新 resource.json 元数据、以及重写 OpenClaw 配置,从而避免将 API Key 写入持久存储 任何其它位置。
  • 目录结构说明 –
    • azure.yaml:定义 AZD 服务和运行信息。
    • infra/:Bicep 模板用于资源部署。
    • scripts/:启动后被复制到 /home/<admin>/scripts,包含 set-openclaw.sh、set-dync-dns.sh、set-dns-ali.sh、 update-ddns-a.sh、update-apikey.sh 等 helper。

请在部署前确保 vmAdminPassword 等必填参数已经设置。如果需要,通过 scripts/set-dync-dns.sh 填写阿里云 DNS 信息以启用动态公网 IP 更新。

ToDo

(@20260322)调整openclaw.json的注入,修复不必要的数据引发的报错,提供远程连接等需要的字 (done@20260325)

(@20260322)添加开启远程连接的脚本。目前选项有 禁用设备验证 (面向全网,但不安全,需给提示)、使用Candy(面向全网,等我慢慢玩通)、 使用Tailscale(仅面向受控节点,等我慢慢验证Azure VM的节点)。 SSH方式计划放在md里说明。(disableDevAuth, SSH tunnel done@20260325)

(@20260410)添加Copilot CLI的安装和配置ACP。copilot的aka.ms链接坏了,改gh.io了。(待测)添加小配置VM的优化:opt-vps&arm.sh。发现之前VM配置低有时候响应慢。(待测)

About

Deploy OpenClaw to Azure VM and use models on Foundry by 1-click.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages