【发布时间】:2019-08-23 19:51:57
【问题描述】:
我有以下 powershell 命令创建一个带有 1 个容器实例的 Azure 容器组:
az container create \
-g $(ResourceGroup) \
--name $(ContainerName) \
--image $(DockerImage) \
--cpu 2 --memory 8 \
--restart-policy OnFailure \
--vnet $(VNet) \
--subnet $(VNetSubnet) \
--registry-username $(RepositoryUserName) \
--registry-password $(RepositoryPassword)
我正在尝试使用 .NET 客户端库来做同样的事情,基于 sample code:
var containerGroup = _azure.ContainerGroups
.Define(agentName)
.WithRegion(resourceGroup.Region)
.WithExistingResourceGroup(resourceGroup.Name)
.WithLinux()
.WithPrivateImageRegistry("xxx.azurecr.io", "xxx", "xxx")
.WithoutVolume()
.DefineContainerInstance(agentName)
.WithImage(args.DockerImageName)
.WithExternalTcpPort(80)
.WithCpuCoreCount(args.CpuCoreCount)
.WithMemorySizeInGB(args.MemorySizeInGB)
.Attach()
.WithTags(tags)
.WithRestartPolicy(ContainerGroupRestartPolicy.Always)
.CreateAsync()
但我找不到设置 vnet 和子网的方法。用 C# 怎么做?
【问题讨论】:
-
我仍然不明白如何使用 fluent API 设置网络配置文件,我觉得当前版本无法做到这一点 - 但无论如何感谢@4c74356b41。
-
是的,我没有使用 c# sdk,所以真的帮不上忙
-
还有两年 - 仍然不可能 (c) Microsoft
-
@cortisol 仅供参考,我们停止使用 ACI,我们将所有容器移至 AKS。
标签: c# azure docker azure-container-registry azure-container-instances