大网数据广告活动
服务器运维问答

Terraform Upload Azure File Share

· 52CE 我爱测

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 c…

问题原文

原帖链接 · Seffyroff · CC BY-SA 3.0

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.

已采纳解答

原帖链接 · Shui shengbao · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-11-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。