I have the following powershell command that creates an Azure container group with 1 container instance:
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)
I'm trying to do the same using the .NET Client Libraries, based on this 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()
But I can't find a way to set the vnet and subnet. How to do it using C#?