# Microsoft Azure Blob Storage Export Integration [Learn more about Microsoft Azure Blob Storage Import Integration](/int/microsoft-azure-blob-storage-import-integration). This article explains how to write job results directly to your Microsoft Azure Blob Storage. For sample workflows of exporting to Microsoft Azure Blob Storage, view [Treasure Boxes](https://github.com/treasure-data/treasure-boxes/tree/master/td/microsoft-azure-blob-storage). # Prerequisites - Basic knowledge of Treasure Data, including the [TD Toolbelt](https://toolbelt.treasuredata.com/). - A Microsoft Azure Platform account # Create Azure Storage Account First, you need to create an Azure Storage account. Here’s documentation about how to create it. - [About Azure storage accounts](https://azure.microsoft.com/en-us/documentation/articles/storage-create-storage-account/) In the Azure Portal, navigate to your storage account, select All Settings, and then select Access keys to obtain account access keys. # Usage ## Create the Destination Container in Microsoft Azure Blob Storage Create your container of Azure Blob Storage from your Azure portal. Also, check the [Naming and Referencing Containers, Blobs, and Metadata](https://docs.microsoft.com/ja-jp/rest/api/storageservices/fileservices/naming-and-referencing-containers--blobs--and-metadata) roles. ## Write the Query Visit the TD Console query editor page and compile your query. ## Specify the Result Export target In the same window, select the Add button in the Result Export section and select Microsoft Azure Blob Storage from the drop-down menu. Edit all of your credentials information, including your Account Name, Account Key, Container, and Path. ![](/assets/image-20191107-182630.d33b66f49102af253c7cc6ae5d90c89c1e2328a4d27bb7061236692bb5d4cfe4.bb266833.png) ## Configure Export Results in Your Data Connection 1. Navigate to **Data Workbench** > **Queries.** 2. Select an existing query or create a new one**.** 3. In the query editor, select the **Export Results** checkbox.![](/assets/image2021-8-17_20-33-4.a5e1beb2a75835482ad65c86de342415a46e1053067a947e80d75386e64f7ae3.bb266833.png) 4. Select your Microsoft Azure connection 5. The Export Results dialog pane opens. Edit the following parameters. | **Parameters** | **Description** | | | --- | --- | --- | | Container (container) | Azure blob container name | | | Path prefix (path_prefix) | Files will be stored at this path | | | Blob Type (blob_type) | **UNSPECIFIED** or **BLOCK_BLOB**. Specify **BLOCK_BLOB** if your result is very large | | | Format (format) | The output file format (csv or tsv) | | | Compression (Encoders) | Compress output file. Supported compressions: Gzip or Bzip2 (gz / bz2) | | | public_key | The public key to use for encryption | String | | key_identifier | Specifies the Key ID of the encryption subkey used to secure the file. The master key is excluded from the encryption process. (string, required) | String | | amor | Use ASCII armor for the encrypted output (boolean) | Boolean | | compression_type | The compression type determines whether to compress the data before encrypting it. Supported values - gzip -->  For example, file extension will be .csv.gz.gpg - bzip2 --> For example, file extension will be .csv.bz2.gpg - none --> For example, file extension will be .csv.gpg - zip_builtin --> For example, file extension will be .csv.zip.gpg - zlip_builtin --> For example, file extension will be .csv.z.gpg - bzip2_builtin --> For example, file extension will be .csv.bz2.gpg**Note: Please ensure that you compress your file before encrypting and uploading. When you decrypt it, the file will revert to its original compressed format, such as .gz or .bz2.** | String | | Delimiter (delimiter) | Delimiter character such as "," for CSV, "\t" for TSV, " | " or any single-byte character | | Null string (null_string) | Use this value to represent NULL values. Defaults to an empty string | | | End-of-line character (newline) | End of line character of the result file | | ## Execute the query Either save the query with a name and run or just run the query. Upon successful completion of the query, the results are automatically imported to the specified container destination. ### (Optional) Schedule Query Export Jobs You can use Scheduled Jobs with Result Export to periodically write the output result to a target destination that you specify. Treasure Data's scheduler feature supports periodic query execution to achieve high availability. When two specifications provide conflicting schedule specifications, the specification requesting to execute more often is followed while the other schedule specification is ignored. For example, if the cron schedule is `'0 0 1 * 1'`, then the 'day of month' specification and 'day of week' are discordant because the former specification requires it to run every first day of each month at midnight (00:00), while the latter specification requires it to run every Monday at midnight (00:00). The latter specification is followed. #### Scheduling your Job Using TD Console 1. Navigate to **Data Workbench > Queries** 2. Create a new query or select an existing query. 3. Next to **Schedule**, select None. ![](/assets/image2021-1-15_17-28-51.f1b242f6ecc7666a0097fdf37edd1682786ec11ef80eff68c66f091bc405c371.0f87d8d4.png) 4. In the drop-down, select one of the following schedule options: ![](/assets/image2021-1-15_17-29-47.45289a1c99256f125f4d887e501e204ed61f02223fde0927af5f425a89ace0c0.0f87d8d4.png) | Drop-down Value | Description | | --- | --- | | Custom cron... | Review [Custom cron... details](#custom-cron-details). | | @daily (midnight) | Run once a day at midnight (00:00 am) in the specified time zone. | | @hourly (:00) | Run every hour at 00 minutes. | | None | No schedule. | #### Custom cron... Details ![](/assets/image2021-1-15_17-30-23.0f94a8aa5f75ea03e3fec0c25b0640cd59ee48d1804a83701e5f2372deae466c.0f87d8d4.png) | **Cron Value** | **Description** | | --- | --- | | `0 * * * *` | Run once an hour. | | `0 0 * * *` | Run once a day at midnight. | | `0 0 1 * *` | Run once a month at midnight on the morning of the first day of the month. | | "" | Create a job that has no scheduled run time. | ``` * * * * * - - - - - | | | | | | | | | +----- day of week (0 - 6) (Sunday=0) | | | +---------- month (1 - 12) | | +--------------- day of month (1 - 31) | +-------------------- hour (0 - 23) +------------------------- min (0 - 59) ``` The following named entries can be used: - Day of Week: sun, mon, tue, wed, thu, fri, sat. - Month: jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec. A single space is required between each field. The values for each field can be composed of: | Field Value | Example | Example Description | | --- | --- | --- | | A single value, within the limits displayed above for each field. | | | | A wildcard `'*'` to indicate no restriction based on the field. | `'0 0 1 * *'` | Configures the schedule to run at midnight (00:00) on the first day of each month. | | A range `'2-5'`, indicating the range of accepted values for the field. | `'0 0 1-10 * *'` | Configures the schedule to run at midnight (00:00) on the first 10 days of each month. | | A list of comma-separated values `'2,3,4,5'`, indicating the list of accepted values for the field. | `0 0 1,11,21 * *'` | Configures the schedule to run at midnight (00:00) every 1st, 11th, and 21st day of each month. | | A periodicity indicator `'*/5'` to express how often based on the field's valid range of values a schedule is allowed to run. | `'30 */2 1 * *'` | Configures the schedule to run on the 1st of every month, every 2 hours starting at 00:30. `'0 0 */5 * *'` configures the schedule to run at midnight (00:00) every 5 days starting on the 5th of each month. | | A comma-separated list of any of the above except the `'*'` wildcard is also supported `'2,*/5,8-10'`. | `'0 0 5,*/10,25 * *'` | Configures the schedule to run at midnight (00:00) every 5th, 10th, 20th, and 25th day of each month. | 1. (Optional) You can delay the start time of a query by enabling the Delay execution. ### Execute the Query Save the query with a name and run, or just run the query. Upon successful completion of the query, the query result is automatically exported to the specified destination. Scheduled jobs that continuously fail due to configuration errors may be disabled on the system side after several notifications. (Optional) You can delay the start time of a query by enabling the Delay execution. ## Activate a Segment in Audience Studio You can also send segment data to the target platform by creating an activation in the Audience Studio. 1. Navigate to **Audience Studio**. 2. Select a parent segment. 3. Open the target segment, right-mouse click, and then select **Create Activation.** 4. In the **Details** panel, enter an Activation name and configure the activation according to the previous section on Configuration Parameters. 5. Customize the activation output in the **Output Mapping** panel. ![](/assets/ouput.b2c7f1d909c4f98ed10f5300df858a4b19f71a3b0834df952f5fb24018a5ea78.8ebdf569.png) - Attribute Columns - Select **Export All Columns** to export all columns without making any changes. - Select **+ Add Columns** to add specific columns for the export. The Output Column Name pre-populates with the same Source column name. You can update the Output Column Name. Continue to select **+ Add Columns**to add new columns for your activation output. - String Builder - **+ Add string** to create strings for export. Select from the following values: - String: Choose any value; use text to create a custom value. - Timestamp: The date and time of the export. - Segment Id: The segment ID number. - Segment Name: The segment name. - Audience Id: The parent segment number. 1. Set a **Schedule**. ![](/assets/snippet-output-connector-on-audience-studio-2024-08-28.a99525173709da1eb537f839019fa7876ffae95045154c8f2941b030022f792c.8ebdf569.png) - Select the values to define your schedule and optionally include email notifications. 1. Select **Create**. If you need to create an activation for a batch journey, review [Creating a Batch Journey Activation](/products/customer-data-platform/journey-orchestration/batch/creating-a-batch-journey-activation). ## Usage from CLI You can also use CLI for Result Export to Microsoft Azure Blob Storage. ## account_name/account_key case ```bash td query --result '{"type":"azure_blob_storage","account_name":"xxxx","account_key":"xxxx","container":"xxxx","path_prefix":"/path/to/file.csv","sequence_format":"","header_line":true,"quote_policy":"MINIMAL","delimiter":",","null_string":"","newline":"CRLF"}' -d sample_datasets "select * from www_access" -T presto ``` ## Optional Configure Export Results in Workflow Within Treasure Workflow, you can specify the use of this data connector to output data. ```yaml timezone: UTC   _export: td: database: sample_datasets   +td-result-into-target: td>: queries/sample.sql result_connection: my_azure_blob result_settings: container: test_container path_prefix: /path/to/file.csv format: csv blob_type: BLOCK_BLOB ``` Learn more about using data connectors to [export data](https://docs.treasuredata.com/articles/project-product-documentation/exporting-data-from-treasure-data) in workflows using CLI. ## References - The Embulk-encoder-Encryption document: [https://docs.treasuredata.com/articles/#!project-integrations/~embulk-encoder-encryption-pgp](/int/embulk-encoder-encryption-pgp)