2

As part of an Azure ACI definition Terraform script, I'm creating an azurerm_storage_share which I want to then upload some files to, before mounting to my container.

As far as I can tell, the right way to access the share once created is via SMB. This rules out all the Terraform provisioners (except local-exec) which support only SSH or WinRM.

So I'm thinking the most efficient, maintainable way to do this is to local-exec to a script that runs azure-cli commands like az storage upload ... ? That way TF does what it does best (orchestration) and have az do config provisioning.

1

Yes, you are right. Terrafrom could not directly access to Azure File share and upload files to it.

Based on my knowledge, maybe you could store your files in a Linux VM and install Azure Cli 2.0 on it. Then you could write a script to upload files to Azure file share like below:

#!/bin/bash
# A simple Azure Storage example script

export AZURE_STORAGE_ACCOUNT=<storage_account_name>
export AZURE_STORAGE_ACCESS_KEY=<storage_account_key>

az storage file upload --share-name myshare --source ~/temp/samplefile.txt

More information about this please refer to this link.

Then you could SSH to this VM and execute this script on Terraform.

| improve this answer | |
  • Thanks. It's a working solution, I'll give it a try. I would prefer something that doesn't require an intermediate VM to spin up, perform configuration, then tear down again, but it looks to be the only way right now. I can't see a serverless solution either. Actually, rolling another container to perform configuration would probably make the most sense. – Seffyroff Nov 22 '17 at 18:54
  • @TheOperator Based on my knowledge, it is not possible with a server to execute a script. – Shui shengbao Nov 23 '17 at 0:31
  • Given that the container I'm deploying is actually a custom web server running a webapp, might I actually be better off using the web app for containers service? Is that service implemented in Terraform? – Seffyroff Nov 23 '17 at 19:17
  • Hi, web app do you mean Azure web app(Paas) or web app on a VM? – Shui shengbao Nov 24 '17 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.