In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. Set up your security questions now so you can recover your account anytime, just log out and back in to get started. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

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

Azure Blob Storage Download & Upload Tool

fajar_wimar
メテオロイド

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!

11件の返信11
Archaeopteryx
ファイアボール

Hi

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

 

 

meghak1590
メテオール

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
メテオール

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
アステロイド

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
メテオール

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
アトム

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

tatemunja
メテオロイド

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

 

Thanks,

thisceci
メテオール

The python code can be found when you right click the Azure Blob tool, and Open Macro.

JackyAndriniaina
アトム

Hello, thanks for the solution. It's work for me one time and after i got this error:

Error: Azure Blob Upload (2): Tool #12: ---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-81a1ac2f03a3> in <module>
15 local_folder_path = param.values[8][1]
16
---> 17 blob_service_client = BlobServiceClient.from_connection_string(connect_str)
18
19 if upload_from_alteryx == 'True':
~\AppData\Roaming\Python\Python38\site-packages\azure\storage\blob\_blob_service_client.py in from_connection_string(cls, conn_str, credential, **kwargs)
175 :caption: Creating the BlobServiceClient from a connection string.
176 """
--> 177 account_url, secondary, credential = parse_connection_str(conn_str, credential, 'blob')
178 if 'secondary_hostname' not in kwargs:
179 kwargs['secondary_hostname'] = secondary
~\AppData\Roaming\Python\Python38\site-packages\azure\storage\blob\_shared\base_client.py in parse_connection_str(conn_str, credential, service)
364 conn_settings = [s.split("=", 1) for s in conn_str.split(";")]
365 if any(len(tup) != 2 for tup in conn_settings):
--> 366 raise ValueError("Connection string is either blank or malformed.")
367 conn_settings = dict((key.upper(), val) for key, val in conn_settings)
368 endpoints = _SERVICE_PARAMS[service]
ValueError: Connection string is either blank or malformed.

ラベル
トップのソリューション投稿者