如何使用Terraform COde下载上传到Azure存储容器的filename.xml

uqxowvwt  于 2023-04-22  发布在  其他
关注(0)|答案(1)|浏览(107)

能够上传blob使用下面。寻找类似的TF代码要么得到文件的内容(或)下载文件使用Terraform代码

resource "azurerm_storage_blob" "example" {
  name                   = "example-blob"
  storage_account_name   = azurerm_storage_account.example.name
  storage_container_name = azurerm_storage_container.example.name
  type                   = "Block"
  source                 = "/path/to/local/file.txt"
  
  metadata = {
    "foo" = "bar"
    "hello" = "world"
  }
}
vuktfyat

vuktfyat1#

能够上传blob使用下面.寻找类似的TF代码要么得到文件的内容(或)下载文件usingTerraform代码.
我已经使用下面的Terraform代码Azure blob下载文件。

provider  "azurerm" {
features {}
}
data  "azurerm_storage_account"  "rkdestorage" {
name =  "rkdestorage"
resource_group_name =  "RK-DataExplorer-Training"
}
data  "azurerm_storage_container"  "sample-100" {
name =  "sample-100"
storage_account_name =  data.azurerm_storage_account.rkdestorage.name
}
data  "azurerm_storage_blob"  "sample_blob" {
name =  "date.txt"
storage_container_name =  data.azurerm_storage_container.sample-100.name
storage_account_name =  data.azurerm_storage_account.rkdestorage.name
}
resource  "local_file"  "sample" {
content =  data.azurerm_storage_blob.sample_blob.name
filename =  "C:\\date.txt"
}

Terraform申请:

我从Azure blob下载了**'date.txt'**文件到我的本地目录。

一旦运行上述terraform代码文件下载到本地路径成功。

参考:local_file (Resource)

相关问题