Skip to content

azurermStorageBlob

Manages a Blob within a Storage Container.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermStorageAccountExample = new azurerm.storageAccount.StorageAccount(
  this,
  "example_1",
  {
    account_replication_type: "LRS",
    account_tier: "Standard",
    location: azurermResourceGroupExample.location,
    name: "examplestoracc",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageAccountExample.overrideLogicalId("example");
const azurermStorageContainerExample =
  new azurerm.storageContainer.StorageContainer(this, "example_2", {
    container_access_type: "private",
    name: "content",
    storage_account_name: azurermStorageAccountExample.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageContainerExample.overrideLogicalId("example");
const azurermStorageBlobExample = new azurerm.storageBlob.StorageBlob(
  this,
  "example_3",
  {
    name: "my-awesome-content.zip",
    source: "some-local-file.zip",
    storage_account_name: azurermStorageAccountExample.name,
    storage_container_name: azurermStorageContainerExample.name,
    type: "Block",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageBlobExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the storage blob. Must be unique within the storage container the blob is located. Changing this forces a new resource to be created.

  • storageAccountName - (Required) Specifies the storage account in which to create the storage container. Changing this forces a new resource to be created. Changing this forces a new resource to be created.

  • storageContainerName - (Required) The name of the storage container in which this blob should be created. Changing this forces a new resource to be created.

  • type - (Required) The type of the storage blob to be created. Possible values are append, block or page. Changing this forces a new resource to be created.

  • size - (Optional) Used only for page blobs to specify the size in bytes of the blob to be created. Must be a multiple of 512. Defaults to 0. Changing this forces a new resource to be created.

\~> Note: size is required if sourceUri is not set.

  • accessTier - (Optional) The access tier of the storage blob. Possible values are archive, cool and hot.

  • cacheControl - (Optional) Controls the cache control header content of the response when blob is requested .

  • contentType - (Optional) The content type of the storage blob. Cannot be defined if sourceUri is defined. Defaults to application/octetStream.

  • contentMd5 - (Optional) The MD5 sum of the blob contents. Cannot be defined if sourceUri is defined, or if blob type is Append or Page. Changing this forces a new resource to be created.

\~> NOTE: This property is intended to be used with the Terraform internal filemd5 and md5 functions when source or sourceContent, respectively, are defined.

  • source - (Optional) An absolute path to a file on the local system. This field cannot be specified for Append blobs and cannot be specified if sourceContent or sourceUri is specified. Changing this forces a new resource to be created.

  • sourceContent - (Optional) The content for this blob which should be defined inline. This field can only be specified for Block blobs and cannot be specified if source or sourceUri is specified. Changing this forces a new resource to be created.

  • sourceUri - (Optional) The URI of an existing blob, or a file in the Azure File service, to use as the source contents for the blob to be created. Changing this forces a new resource to be created. This field cannot be specified for Append blobs and cannot be specified if source or sourceContent is specified.

  • parallelism - (Optional) The number of workers per CPU core to run for concurrent uploads. Defaults to 8. Changing this forces a new resource to be created.

\~> NOTE: parallelism is only applicable for Page blobs - support for Block Blobs is blocked on the upstream issue.

  • metadata - (Optional) A map of custom blob metadata.

Attributes Reference

The following attributes are exported in addition to the arguments listed above:

  • id - The ID of the Storage Blob.
  • url - The URL of the blob

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Storage Blob.
  • update - (Defaults to 30 minutes) Used when updating the Storage Blob.
  • read - (Defaults to 5 minutes) Used when retrieving the Storage Blob.
  • delete - (Defaults to 30 minutes) Used when deleting the Storage Blob.

Import

Storage Blob's can be imported using the resourceId, e.g.

terraform import azurerm_storage_blob.blob1 https://example.blob.core.windows.net/container/blob.vhd