未经同意请勿转载TL;DRAzure Local 2606 在Hyperconverged单集群、超融合路径下创建 VM完整流程分为两大阶段阶段 1前置条件订阅 RBAC Resource Group VM image Custom Location Network Interface阶段 2创建 VM5 种部署方式CLI / Portal / ARM / Bicep / Terraform 3 类 VM 类型Standard / Trusted Launch / Dynamic Memory 3 类扩展能力Proxy / Arc Gateway / Managed Identity本篇按先 prereqs、再 create的叙事主线展开。Multi-rack 路径见第 2 篇。作者声明本文中所有 Prerequisites 项、命令、参数、限制条件均直接引用自 Microsoft Learn 官方页面Create Azure Local Virtual Machines Enabled by Azure Arc作者总结小节是作者对官方文档中容易踩坑或术语严谨性的整理文中显式标注 [误区] 与 [作者总结] 区分官方原话。文档版本azloc-26062026 年 7 月视图。〇、HC vs MR 路径选型速查5 秒决策业务需求HC 路径MR 路径单集群 / 单机房✅ 典型场景✅ 可用但偏重多机架 / 跨机房❌ 不适用✅ 典型场景Trusted Launchsecure boot vTPM✅ 支持❌ 不支持Dynamic Memory✅ 支持❌ 不支持Availability Zone机架级容灾❌ 不适用✅--zoneStrict Placement❌ 不适用✅--strict-placementArc Gateway✅ 支持❌ 不支持Marketplace 镜像✅ 支持❌ 仅 Storage accountLinux 仅 Ubuntu Server Proxy✅ 验证✅ 强制Proxy 强制❌ 建议✅ 强制一句话选型HC 路径单集群、需要 Trusted Launch / Dynamic Memory / Arc Gateway / Marketplace 镜像MR 路径多机架、需要机架级容灾、可接受 Standard Static 内存降级如果选 MR 路径请看 第 2 篇 · Multi-Rack 完整实战。第一部分前置条件Prerequisites一、为什么 Hyperconverged 的 Prerequisites 只有一页维度Hyperconverged本篇Multi-rack第 2 篇Prerequisites 位置内嵌在create-arc-virtual-machines综合页独立页multi-rack-vm-management-prerequisites章节结构1 段含 5 种 tab5 个 H2 章节网络底座单一 logical networkNetwork Fabric L3 isolation domainVM image 要求仅列 3 种来源链接明确内容要求en-us / cloud-init / serial / VirtIO客户端 CLI1 项 prereq5 步流程含 extension 安装二、共同 Prerequisites5 种部署方式都必须满足的 5 项无论选择 Azure CLI / Azure Portal / ARM template / Bicep template / Terraform template 中哪一种下面 5 项是必须的2.1 Azure 订阅 RBAC 角色官方原文5 种 tab 全部包含Access to an Azure subscription with the appropriate Azure role-based access control (RBAC) role and permissions assigned. For more information, see RBAC roles for Azure Local VM management.角色配置细节见官方 assign-vm-rbac-roles 页面HC 路径下沿用通用 built-in RBACMR 路径推荐Infrastructure admin / Application admin双角色模型部署时只需要订阅级访问即可2.2 Resource Group资源组官方原文5 种 tab 全部包含Access to a resource group where you want to provision the VM.微软官方建议For ease of management, we recommend that you use the same resource group as your Azure Local instance.VM 与 Azure Local instance 同 RG 是建议做法——不强求跨 RG 引用资源disk / NIC / image / storage path时必须传完整 ARM resource ID2.3 VM imagesVM 镜像官方原文5 种 tab 全部包含Access to one or more VM images on your Azure Local instance.三种来源VM image starting from an image in Azure MarketplaceVM image starting from an image in an Azure Storage accountVM image starting from an image in a local share来源适用场景Azure Marketplace公开发行版 OSUbuntu / Windows Server 等Azure Storage account客户上传到 Azure Storage 的自定义镜像本地共享local share本地 VHDX / 离线拷贝的镜像作者展开galleryImage 是集群级资源——创建后可在多个 VM 创建命令中复用三种来源是互斥的或关系——一次 VM 创建命令只用一种 imageMR 路径仅支持 Storage account——其他两种来源在 MR 下不可用2.4 Custom Location自定义位置官方原文5 种 tab 全部包含A custom location for your Azure Local instance that you use to provision VMs. The custom location shows up on theOverviewpage for your Azure Local instance.Custom Location 是在 Azure Arc 注册 Azure Local 时自动创建的 ARM 资源RPMicrosoft.ExtendedLocation/customLocationsVM 创建命令中通过--custom-location参数传入 ARM resource IDCustom Location 不是 Azure 区域——它是 Azure Local 集群定位符2.5 Network Interface网络接口官方原文CLI tab 包含Access to a network interface that you created on a logical network associated with your Azure Local instance.官方原文ARM / Bicep / Terraform tabAccess to a logical network that you associate with the VM on your Azure Local instance.CLI 部署可以直接引用已创建的 NICARM / Bicep / Terraform 部署通常引用logical network必须至少有 1 个 NIC 才能启用 guest management——这是官方明确要求三、5 种部署方式差异项速查部署方式比共同项多需要的 prereqAzure CLIaz客户端已创建好的 NIC可选 storage pathAzure Portal仅共同项ARM templateGitHubaka.ms/hci-vmarmtemp模板logical networkBicep templateaka.ms/hci-vmbiceptemplate模板logical networkTerraform templateTerraform v1.9.8 Git 4 个 providerazure/azapi/azure/modtm/hashicorp/azurerm/hashicorp/randomlogical network作者总结Azure Portal 路径 prereq 最小——浏览器 Azure 订阅即可ARM / Bicep 路径需要 sample template——微软在 GitHubazure-quickstarts仓库维护Terraform 路径 prereq 最复杂——Terraform CLI Git 多个 Azure provider四、VM images 是 VM 创建的上游依赖Azure Local 集群已注册到 Arccustom location 存在 ├─► galleryImageVM image三种来源 │ ├─ Marketplace 镜像 │ ├─ Storage account 镜像 │ └─ Local share 镜像 ├─► logicalNetwork / virtualNetwork网络底座 ├─► networkInterface绑定到 logical network └─► VM 实例绑定 image NIC custom location第二部分创建 VM实战命令五、两条总前提前提文档出处Provisioning State SucceededThe VM is successfully created when theprovisioningStateparameter appears assucceededin the output.Guest Management 默认启用The VM created has guest management enabled by default. If for any reason guest management fails during VM creation, follow the steps in Enable guest management on the Azure Local VM...作者展开两个 DVD drives 默认创建——VM 配置过程中会临时挂载两个 ISO 文件用于 guest agent 安装成功后 ISO 被删除但 Windows Device Manager / Linux dmesg 可能仍看到空 DVD 设备跨 RG 引用资源必须传完整 ARM resource ID——disk / NIC / image / storage path六、Azure CLI 路径最常用6.1 准备工作az login --use-device-code az account set --subscription Subscription ID6.2 必填参数速查参数说明--nameVM 名称--resource-groupVM 所在 RG--admin-usernameVM 管理员用户名--admin-passwordVM 管理员密码--imageVM 镜像名 / ARM resource ID--locationAzure 区域eastus/westeurope--custom-locationCustom Location ARM resource ID--nicsNIC 名称或 ID至少 1 个--authentication-typeall/password/ssh--memory-mb内存 MB--processorsvCPU 数--storage-path-id可选存储路径6.3 三种 VM 类型A. 标准 VMaz stack-hci-vm create \ --name $vmName \ --resource-group $resource_group \ --admin-username $userName \ --admin-password $password \ --computer-name $computerName \ --image $imageName \ --location $location \ --authentication-type all \ --nics $nicName \ --custom-location $customLocationID \ --hardware-profile memory-mb8192 processors4 \ --storage-path-id $storagePathIdB. Trusted Launch VM含 secure boot vTPMaz stack-hci-vm create \ --name $vmName \ --resource-group $resource_group \ --admin-username $userName \ --admin-password $password \ --computer-name $computerName \ --image $imageName \ --location $location \ --authentication-type all \ --nics $nicName \ --custom-location $customLocationID \ --hardware-profile memory-mb8192 processors4 \ --storage-path-id $storagePathId \ --enable-secure-boot true \ --enable-vtpm true \ --security-type TrustedLaunch官方原文关键When you specify that security type asTrustedLaunch, you must enable secure boot and vTPM. Otherwise,TrustedLaunchVM creation fails.作者展开 [误区]❌ 常见误区我可以先创建标准 VM然后再开 Trusted Launch ✅ 真相Trusted Launch不可后开启——必须创建时指定验证 Trusted Launch 生效# 在集群节点上找到 VM owner node Get-ClusterGroup $vmName # 在 owner node 上验证 (Get-VM $vmName).GuestStateIsolationType # 应返回 TrustedLaunchC. Dynamic Memory VMaz stack-hci-vm create \ --name my_dynmemory \ -g my_registration \ --admin-username admin \ --admin-password password \ --custom-location /subscriptions/sub/resourceGroups/rg/providers/Microsoft.ExtendedLocation/customLocations/cl \ --location eastus2euap \ --image /subscriptions/sub/resourceGroups/rg/microsoft.azurestackhci/marketplacegalleryimages/image \ --hardware-profile vm-sizeCustom processors1 memory-mb1024 maximum-memory-mb2048 minimum-memory-mb1024 target-memory-buffer20 \ --enable-agent true \ --nics dynnicDynamic Memory 参数说明vm-sizeCustom必须设为 Custommemory-mb启动内存最少 1024maximum-memory-mb上限≥ memory-mbminimum-memory-mb下限≤ memory-mbtarget-memory-buffer百分比20 20%6.4 Linux VM同一条az stack-hci-vm create命令--image必须指向Linux imageSSH keys--ssh-key-values keyfile--authentication-type ssh用户名密码--authentication-type password官方原文关键Setting the proxy server during VM creation is supported forUbuntu Server VMs.作者总结⚠️ HC 路径下 Linux VM 用 Proxy仅 Ubuntu Server 验证过——其他发行版需手动配置6.5 Windows Server 2012 / 2012 R2 特殊处理官方原文Windows Server 2012 and Windows Server 2012 R2 do not support enabling guest management as this operating system lacks support for Hyper-V sockets which is required for enabling guest management.关键参数--enable-agent false --enable-vm-config-agent falseFlag作用--enable-agent控制 Azure Connected Machine Agent 是否在 VM 内启动--enable-vm-config-agent控制 VM agent 通过 Hyper-V sockets 从 host 注入WS 2012/2012 R2 不支持 Hyper-V sockets七、Azure Portal 路径最少 prereq7.1 5 步流程Azure Arc cluster view→Virtual machines顶部命令栏 → Create VMBasics tab→Project detailsInstance detailsVM extensions→ 启用 Guest Management提交7.2 关键参数字段说明Subscription计费绑定Resource group新建或选已有Virtual machine name小写字母 可含连字符/数字Custom location自动筛选已注册 Azure LocalVirtual machine kind自动设为 Azure LocalSecurity typeStandard或Trusted launchImageMarketplace 镜像 或 客户管理镜像Virtual processor countvCPU 数MemoryMB 单位Memory typeStatic或Dynamic八、ARM template 路径官方 quickstarthttps://aka.ms/hci-vmarmtemp关键差异使用logical networkCLI 用 NIC部署通过az deployment group create触发适用场景与 ARM 标准工作流 / Azure Policy / Blueprints / CI/CD 集成九、Bicep template 路径官方 quickstarthttps://aka.ms/hci-vmbiceptemplate与 ARM 差异更简洁语法 强类型 模块化部署命令az bicep build --file main.bicep az deployment group create --resource-group $resource_group --template-file main.json --parameters parameters.json十、Terraform 路径Azure Verified Module10.1 模块来源Azure Verified Moduleterraform-azurerm-avm-res-azurestackhci-virtualmachineinstance含两个 examplesdefault/1 个 VM、multi/多个 VM10.2 部署流程git clone https://github.com/Azure/terraform-azurerm-avm-res-azurestackhci-virtualmachineinstance cd terraform-azurerm-avm-res-azurestackhci-virtualmachineinstance/examples/default terraform init terraform plan terraform apply10.3 Provider 依赖官方示例Provider版本hashicorp/azurermv3.116.0azure/azapiv1.15.0azure/modtmv0.3.2hashicorp/randomv3.6.3Terraform CLIv1.9.8十一、3 类扩展能力11.1 Proxy 配置生产环境必备官方原文Use the optional parameterproxy-configurationto configure a proxy server for your VM.子参数说明http_proxyHTTP 代理 URLhttps_proxyHTTPS 代理 URL仍可用 HTTP 地址no_proxy绕过代理的 URL 列表cert_file_path代理服务器证书路径典型命令含认证az stack-hci-vm create ... \ --proxy-configuration \ http_proxyhttp://ubuntu:***192.168.200.200:3128 \ https_proxyhttp://ubuntu:***192.168.200.200:3128 \ no_proxylocalhost,127.0.0.1,.svc,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,100.0.0.0/8,s-cluster.test.contoso.com \ cert_file_pathC:\ClusterStorage\UserStorage_1\server.crt官方原文重要警告Dont passcert_file_path(an empty value), because the command fails when it tries to open a nonexistent file.作者总结 [误区]❌ 常见误区配了 ProxyVM 内所有流量都走代理 ✅ 真相Proxy只设置环境变量给 Azure Connected Machine Agent。浏览器 / WinInet / netsh / 用户应用需自己配置11.2 Arc Gateway简化网络配置官方原文Configure the Azure Arc gateway to reduce the number of required endpoints that are needed to provision and manage Azure Local VMs with the Azure Connected Machine Agent.# 不带 Proxy az stack-hci-vm create ... --gateway-id $gw # 带 Proxy az stack-hci-vm create ... --gateway-id $gw \ --proxy-configuration http_proxy... https_proxy... no_proxy... cert_file_path...端点白名单必须放行For Windows VMs, allow the following endpoints:https://agentserviceapi.guestconfiguration.azure.comandhttps://azurelocalregion-gas.guestconfiguration.azure.com.For Linux VMs, allow the following endpoints:https://agentserviceapi.guestconfiguration.azure.com,https://azurelocalregion-gas.guestconfiguration.azure.com, andhttps://packages.microsoft.com.端点WindowsLinuxagentserviceapi.guestconfiguration.azure.com✅✅azurelocalregion-gas.guestconfiguration.azure.com✅✅packages.microsoft.com❌✅作者总结⚠️Linux 多一个端点packages.microsoft.com用于 apt/yum/zypper 包管理。这条容易被遗漏 ⚠️MR 路径 Arc Gateway 不支持——见第 2 篇11.3 Managed Identity自动启用官方原文When the VMs are created on your Azure Local instance via the Azure CLI or the Azure portal, asystem-assigned managed identityis also created that lasts for the lifetime of the VMs.The VMs on your Azure Local instance are extended from Azure Arc-enabled servers and can use system-assigned managed identity to access other Azure resources that support authentication based onMicrosoft Entra ID.For example, the VMs can use a system-assigned managed identity to accessAzure Key Vault.作者展开Azure Local VM 启用 Guest Management 后自动注册到 Azure Arc成为 Arc-enabled serversystem-assigned managed identity不需要az identity assign——全自动可直接访问 Azure Key Vault / Azure Storage / Azure SQL 等支持 Microsoft Entra ID 认证的资源十二、5 种部署方式 × 3 类能力交叉速查能力Azure CLIPortalARMBicepTerraformTrusted Launch✅✅✅✅✅Dynamic Memory✅✅✅✅✅Proxy✅✅✅✅✅Arc Gateway✅✅✅✅✅WS 2012/2012 R2✅✅✅✅✅Linux Ubuntu Proxy✅✅✅✅✅system-assigned MI✅✅✅✅✅第三部分常见误区、Takeaway、附录十三、常见误区误区 1我准备用 Portal为什么还需要 az CLI真相Azure Portal 路径不需要 az CLI——这是 Azure CLI tab 的专属 prereq。但其他 4 种部署方式都需要各自工具链CLI / ARM / Bicep / Terraform。误区 2创建 VM 时一定要装 Guest Management真相Guest Management默认启用但Windows Server 2012 / 2012 R2 不支持。WS 2012/2012 R2 → 必须--enable-agent false--enable-vm-config-agent false。误区 3Custom Location 是个 Azure 区域吗真相不是 Azure 区域——是 Azure Arc 体系下的扩展定位符。Azure 区域参数--location eastus依然需要Custom Location 是叠加在 Azure 区域之上的 Azure Local 集群定位。误区 4Trusted Launch 创建后可以再开启真相不可后开启。--security-type TrustedLaunch是创建时参数。误区 5HC 也强制 Proxy真相HC 路径 Proxy 是建议Use the optional parameter。MR 路径才是强制。误区 6cert_file_path 可以传空字符串真相绝对不可以——命令会失败找不到文件。误区 7Arc Gateway 可以替代 Proxy真相不完全替代——Arc Gateway 只接管 Azure Arc 流量企业应用流量仍走 Proxy / 防火墙。误区 8我配了 Linux 端点白名单但 Linux VM 装包仍失败真相Linux 比 Windows 多一个端点https://packages.microsoft.com——不在 Windows 列表里。十四、TakeawayHC 路径 Prerequisites 内嵌——5 种部署方式共用 5 项 prereqAzure Portal 路径 prereq 最小——浏览器 Azure 订阅即可ARM / Bicep 路径多需要 sample template——GitHubazure-quickstarts仓库Terraform 路径 prereq 最复杂——Terraform CLI 4 个 provider GitVM image 是 VM 创建的上游——Marketplace / Storage account / Local share 三选一Custom Location 不是 Azure 区域——是 Azure Local 集群定位符Provisioning State Succeeded 是创建成功的唯一标志Guest Management 默认启用——WS 2012/2012 R2 必须显式 falseTrusted Launch 不可后开启——必须创建时指定Proxy 是建议HC/强制MR——Multi-rack 不配 Proxy → Guest Management 失败cert_file_path 不能传空字符串——否则命令失败Arc Gateway 简化端点——但 Linux 多packages.microsoft.com一条system-assigned managed identity 自动创建——不需要az identity assign附录 A术语约定术语含义Azure Local VM运行在 Azure Local 集群上、已注册到 Azure Arc 的 VM资源类型Microsoft.AzureStackHCI/virtualMachineInstancesGuest ManagementAzure Connected Machine Agent 在 VM 内的部署能力Custom LocationAzure Arc 扩展定位符标识 Azure Local 集群位置Logical NetworkAzure Local 的网络底座Trusted LaunchVM 安全类型含 secure boot vTPM2602 默认推荐HyperconvergedAzure Local 的经典形态——单集群、超融合Arc GatewayAzure Arc 流量聚合 endpointsystem-assigned managed identityAzure 自动给 VM 分配的托管标识附录 B参考链接主文档Create Azure Local Virtual Machines Enabled by Azure ArcRBAC 角色assign-vm-rbac-rolesVM image 三种来源Marketplace / Storage account / Local shareARM template quickstarthttps://aka.ms/hci-vmarmtempBicep template quickstarthttps://aka.ms/hci-vmbiceptemplateTerraform AVM 仓库terraform-azurerm-avm-res-azurestackhci-virtualmachineinstanceManaged IdentitySystem-assigned managed identities第 2 篇Multi-rack 完整路径Azure-Local-VM-Deploy-02-Multi-Rack.md文档维护本篇对应 azloc-26062026 年 7 月视图。如官方在更高版本拆分 Create VM 章节为按 workload 类型GPU / SQL / AVD的子页面本篇将随之更新。