ALTERYX INSPIRE | Join us this May for for a multi-day virtual analytics + data science experience like no other! Register Now

Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Azure Blob Storage Download & Upload Tool

fajar_wimar
6 - Meteoroid

Hi All,

 

I want to share a macro/tool that can download and upload your file from & to Azure Blob Storage.

In this post, you can download the tool below and you will get Azure_Blob_Storage_Download&Upload.yxzp consists of Download & Upload Tool.

 

This macro is developed by python Code using azure blob API.

 

Before you use the macro, you need to configure your storage connection string by this following steps:

 

1. Sign in to the Azure portal.

2. Go to your storage account.

3. Click the Settings section, select Access keys.

4. Your Connection string value is under key1.

Connection String.png

 

 

 

 

 

5. Open your cmd and enter the following command :

setx AZURE_STORAGE_CONNECTION_STRING "<yourconnectionstring>"

 

Click here for more detail :

https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-python

 

 

1. AZB Download

 

In AZB Download macro, you can specify the container name & server folder path (optional).

You can also download your file in a subdirectory. You can download your file and read directly to Alteryx, or download your file into a local path. When you choose to read the file directly into Alteryx, you only read the csv/xlsx/txt file(s).

 

AZB Download.JPG

 

2. AZB Upload

 

In AZB Upload Tool, you also need to specify the container name & server folder path (optional). You can upload your file from the Alteryx workflow, from a file, or upload it from a local folder. When you uploading your file from Alteryx workflow, you can specify file type (csv, xlsx, or txt) and also specify your sheet name for excel type.

 

Capture.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Thanks!

Archaeopteryx
10 - Fireball

Hi

Is this solution version dependent? Will it work with 2020.3 ?

 

 

meghak1590
7 - Meteor

great solution . but facing this error while running the download macro.

 

Error: Azure Blob Download (1): Tool #1: ---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-7591a47e4e5a> in <module>
1 import os, uuid
----> 2 from azure.storage.blob import BlobServiceClient, BlobClient, ContainerClient
3 import pandas as pd
4 import tempfile
5 from wcmatch import fnmatch
ModuleNotFoundError: No module named 'azure'

Error: Azure Blob Download (1): Tool #1: ---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-b287f6416c58> in <module>
11 localdir = param.values[7][1]
12
---> 13 blob_service_client = BlobServiceClient.from_connection_string(connect_str)
14
15 if is_read_to_alteryx=='True':
NameError: name 'BlobServiceClient' is not defined

Dan_Z
7 - Meteor

Hey meghak1590! 

 

We had the same error pop up over here. We opened the macro, and in the Python tool, the first cell in the code had a typo. Make sure that both references to azure-blob-storage have dashes instead of periods: 

 

Dan_Agenti_0-1609865207317.png

Once we changed that, there was a second module error for "wcmatch". I copied the same syntax from cell one and added it to an additional cell, changing the package from 'azure-storage-blob' to "wcmatch" and that was resolved. My assumption is people with more Python experience (I'm a complete noob) probably have this module already installed. 

 

Dan_Agenti_1-1609865395162.png

 

Unfortunately for us, solving the two module installs left us with storage error exceptions we haven't yet overcome (attached the transcript). Any thoughts on how to handle this hot mess?

 

 

avanibhatnagar
5 - Atom

Hey,

 

@fajar_wimar @Dan_Z @meghak1590 

Would it be possible for you to share the Python code inside the Python tool in the macro? When I download it, it is blank and hence I'm unable to run this macro. I know sometimes Alteryx workflows don't save the code in the Python tool and I'm wondering if that's what happened. 

Dan_Z
7 - Meteor

Hi @avanibhatnagar Unfortunately I don't have the code anymore either. I 'poked around' with using that macro but without much success and abandoned the pursuit for other projects. Sorry I couldn't be more helpful!

brent-reffner
5 - Atom

The tool does not contain the python code.  Can you provide the python code you used behind the scenes for this macro?

tatemunja
6 - Meteoroid

Has there been any further iterations on this? i am getting the "ModuleNotFound Error" that everyone seems to be mentioning. 

 

Thanks,

Labels