You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Azure容器实例Fluent SDK创建Windows容器报错咨询

解决Azure容器实例Fluent SDK创建Windows容器时的OS版本不支持问题

我来帮你搞定这个问题——你遇到的The OS version of image '/:v1' is not supported错误,核心原因是Windows容器镜像的OS版本和Azure容器实例要求的版本不匹配,而Linux容器没有这么严格的版本绑定要求,所以能正常跑起来。下面是具体的解决步骤:

1. 先把镜像的基础信息理清楚

首先,你的镜像路径/:v1看起来明显不完整,得先替换成实际的完整镜像地址(比如your-acr.azurecr.io/your-windows-image:v1或者公共镜像如mcr.microsoft.com/windows/servercore:ltsc2022)。同时要确认这个镜像基于哪个Windows版本,比如是Server Core 2022、Nano Server 1809这类。

2. 在SDK代码中显式指定OS版本

Azure容器实例创建Windows容器时,必须明确指定匹配镜像的OS版本,这一步很关键,你之前的代码应该漏掉了这个配置。修改你的代码,添加OS版本的指定:

var credentials = new AzureCredentials(
    new ServicePrincipalLoginInformation { ClientId = "myid", ClientSecret = "mysecret" },
    "your-tenant-id",
    AzureEnvironment.AzureGlobalCloud
);

var azure = Azure
    .Configure()
    .Authenticate(credentials)
    .WithSubscription("your-subscription-id");

var containerGroup = await azure.ContainerGroups.Define("my-win-container-group")
    .WithRegion(Region.EuropeWest)
    .WithExistingResourceGroup("my-resource-group")
    .WithWindowsOperatingSystem()
    // 这里一定要填和镜像匹配的OS版本,比如ltsc2022、ltsc2019、1809等
    .WithOsVersion("ltsc2022")
    .WithContainerInstance("my-win-container")
        .WithImage("mcr.microsoft.com/windows/servercore:ltsc2022") // 替换成你的实际镜像地址
        .WithExternalTcpPort(80)
        .WithCpuCoreCount(1.0)
        .WithMemorySizeInGB(2.0)
        .Attach()
    .CreateAsync();

3. 确认你的区域支持该Windows版本

不是所有Azure区域都支持所有Windows版本,你可以用Azure CLI命令查一下目标区域支持的OS版本:

az container list-os-options --location europewest --output table

确保你指定的OS版本在列表里,不然还是会报错。

4. 镜像和OS版本必须严格匹配

比如你用了基于ltsc2022的镜像,就不能指定ltsc2019的OS版本,两者必须完全对应,否则Azure会判定版本不兼容。

小提醒:如果你的镜像存在私有容器 registry 里,还要确保代码中配置了正确的仓库认证信息(比如WithRegistryCredential),不过你的错误提示是OS版本问题,这个可以先放在次要位置检查。

内容的提问来源于stack exchange,提问作者Uffe Hansen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:19:55