Ask Your Question
4

What is the process for uploading files to Azure Storage using Terraform in Azure Pipeline?

asked 2021-04-20 11:00:00 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-12 08:00:00 +0000

pufferfish gravatar image

The process for uploading files to Azure Storage using Terraform in Azure Pipeline involves the following steps:

  1. Define the Azure Storage account and the storage container in your Terraform code.
  2. Add your Terraform code to your Azure Pipeline repository.
  3. Configure your Azure Pipeline to run Terraform.
  4. Add the Azure Resource Manager (ARM) provider to your Terraform file.
  5. Use the Terraform "azurermstorageblob" resource to create a new blob container.
  6. Use the Terraform "azurermstorageblob" resource to upload the files to the blob container.

Here's an example of what the Terraform code might look like:

provider "azurerm" {
  features {}
}

resource "azurerm_storage_account" "storage_account" {
  name                     = "my-storage-account"
  resource_group_name      = "my-resource-group"
  location                 = "westus2"
  account_kind             = "StorageV2"
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

resource "azurerm_storage_container" "blob_container" {
  name                  = "my-blob-container"
  storage_account_name  = azurerm_storage_account.storage_account.name
  container_access_type = "private"
}

resource "azurerm_storage_blob" "example" {
  name                   = "example.txt"
  storage_account_name   = azurerm_storage_account.storage_account.name
  storage_container_name = azurerm_storage_container.blob_container.name
  type                   = "Block"
  source                 = "./example.txt"
  content_type           = "text/plain"
}

Once you've added this code to your Azure Pipeline repository and configured your pipeline to run Terraform, the pipeline will automatically create the storage account, the blob container, and upload the example.txt file to the blob container.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-04-20 11:00:00 +0000

Seen: 14 times

Last updated: Aug 12 '21