Azure / azure-libraries-for-net

Azure libraries for .Net
MIT License
378 stars 193 forks source link

How to add secrets volume for azure container instances #1053

Open clement128 opened 4 years ago

clement128 commented 4 years ago

Query/Question I would like to enable a TLS endpoint in a sidecar container, but can't find a way to add a secrets volume. There is a definition here but seems can't be use.

Why is this not a Bug or a feature Request? I found a definition for secrets volume but just not sure how to use it.

Setup (please complete the following information if applicable):

yungezz commented 4 years ago

hi @ChenTanyi could you pls have a quick look?

ChenTanyi commented 4 years ago

@clement128 Maybe it was the stage design error. You can use inner model to workaround it. example:

var aciCreate = azure.ContainerGroups.Define(aciName)
                .WithRegion(Region.USWest)
                .WithNewResourceGroup(rgName)
                .WithLinux()
                .WithPublicImageRegistryOnly()
                .WithoutVolume()
                .DefineContainerInstance("nginx")
                    .WithImage("nginx")
                    .WithoutPorts()
                    .Attach()

            Dictionary<string, string> secret = new Dictionary<string, string>();

            (aciCreate as IContainerGroup).Inner.Volumes.Add(new Volume(name: "random", secret: secret));

            aciCreate.Create();

or use the whole inner if you want

azure.ContainerGroups.Inner.CreateOrUpdateAsync();