我無權訪問存盤帳戶。我僅在容器級別獲得 SAS 令牌。需要將檔案(在容器中創建一個 blob)作為 terraform 中的 blob 上傳到存盤帳戶。
這是我下面的代碼。在哪里使用 SAS 令牌以便在容器中創建 blob。
data "azurerm_storage_account" "eg" {
name = "abc"
resource_group_name = "xyz-rg"
}
resource "azurerm_storage_blob" "test" {
name = "${local.currentdate}_${var.filename}"
storage_account_name = data.azurerm_storage_account.eg.name
storage_container_name = "ctr"
type = "Block"
source = "./myfile.txt"
}
如果我的存盤帳戶在另一個訂閱中,他們是否會遵循代碼塊。我收到ResourceNotFound錯誤。
resource "azurerm_storage_blob" "test" {
provider = azurerm.aabbxx
name = "${local.currentdate}_${var.filename}"
storage_account_name = "mystacc"
storage_container_name = "ctr"
type = "Block"
provisioner "local-exec" {
command = "az storage blob upload --account-name mystacc -f ./myFile.csv -c ctr -n MyBlob --sas-token {SAS-token}"
}
uj5u.com熱心網友回復:
簡單的回答:如果您無權訪問存盤帳戶資源,您將無法像這樣管理/創建 blob。您可以將 local-exec 與 azure CLI 一起使用
像這樣的東西
resource "foo" "bar" {
provisioner "local-exec" {
command = "az storage blob upload -f /path/to/file -c mycontainer -n MyBlob --sas-token {MY-SAS}"
}
}
https://docs.microsoft.com/en-us/cli/azure/storage/blob?view=azure-cli-latest#az-storage-blob-upload
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/426219.html
標籤:天蓝色 地形 天蓝色 blob 存储 天蓝色存储 共享访问签名
