Mohamed Taher
Mohamed Taher

Reputation: 99

Using binary file stored in storage account from python script

I am trying to run a python script (the script resides on a directory in \wwwroot directory in my app file system) from my web app using java, the script uses a binary file (g.bin), the binary file size is huge (3.5+ GB), so I stored it in a storage account (file service), now I want to use the data found in the bin file, How can I open the file using my script? What is the path that the python script should use and how to open it?

Upvotes: 0

Views: 378

Answers (1)

Saher Ahwal
Saher Ahwal

Reputation: 9237

You need to use azure-storage python SDK, and the module you need is azure.storage.file.fileservice

First initialize the FileService

f = FileService(account_name=None, account_
                key=None, sas_token=None,
                protocol=’https’, endpoint_
                suffix=’core.windows.net’,
                request_session=None, connection_
                string=None)

Then you need to download the file to a stream using fileservice.get_file_to_stream method.

f.get_file_to_stream(share_name, directory_name, file_name, stream, start_range=None, end_range=None, validate_content=False, progress_callback=None, max_connections=2, timeout=None, snapshot=None)

Give that a try. If you can't get it to work, update your question with what you tried, and I'll be happy to help.

Upvotes: 1

Related Questions