1

I am deploying a Container group with the template https://learn.microsoft.com/en-us/azure/templates/microsoft.containerinstance/2018-10-01/containergroups

It has command parameter, but it is just a string and runs one command. I would like to run multiple commands when deploying. Is it possible?

If not, is there a way to run those commands to the container after it has been deployed, using PowerShell?

My usecase: I need a SFTP server in Azure for customers to be able to send us data. I then poll that with a Logic App.

What I have done: I found this template to be good for my needs, as it is easier to poll Azure Storage File Share.

https://github.com/Azure/azure-quickstart-templates/blob/master/201-aci-sftp-files

My problem is I have multiple users. Everyone needs their own username/password and their own file share or sub-directory in that share. I also can't understand how to configure multiple users through the environment variable. I tried separating them with ;. It deploys, but the server doesn't respond to requests at all.

I can deploy multiple containers, one for each user, but that doesn't sound like a good idea when the number of customers rises.

SamiR
  • 77
  • 10

1 Answers1

1

Unfortunately, it seems that you cannot run multi-command in one time. See the Restrictions of the exec command for ACI:

Azure Container Instances currently supports launching a single process with az container exec, and you cannot pass command arguments. For example, you cannot chain commands like in sh -c "echo FOO && echo BAR", or execute echo FOO.

I suggest that you can run the command to create an interactive session with the container instance to execute command continuously after you create the ACI.

For Linux:

az container exec -g groupName -n containerName --exec-command "/bin/bash"

For Windows:

az container exec -g groupName -n containerName --exec-command "cmd.exe"

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
  • Thanks! Wouldn't it actually make more sense to just run those command in the PS? Why would I need to deploy a container to run a command to create a share? Is this template just so you can do everything with a JSON? – SamiR Jan 18 '19 at 13:08
  • It just means that the exec command in container group just can run with one command process, not multi. You can create an interactive session to exec multi-commands one by one. The template just does what it can. As for the file share, it can share files between the container groups. – Charles Xu Jan 18 '19 at 13:16
  • But could I just remove the clicontainer from the template and create the file shares in storage with the az container commands and then deploy just the sftp server container with the mounts so they would mount the file shares in storage? Is that clicontainer somehow required as a link? I have tried to do that, but something is wrong. The deployements run without errors, but the sftpserver does not respond, which seems like a common result when something in the configuration is wrong. – SamiR Jan 18 '19 at 13:45
  • If the clicontainer just use to create the storage account. You can ignore it and just create the storage account in the template and then mount it in the sftp. I think the error is a configuration mistake. – Charles Xu Jan 18 '19 at 15:03