0

This is the Python function that my app is using in order to retrieve an Azure text blob. Here is the documentation for the gen_blob_to_text function (when you click on the page, Ctrl+F and search for the name of the function).

def get_text_blob(self, archive_url):
    container, archive_location = paths.extract_url_elements(archive_url)

    blob = None
    try:
        blob = self.blob_service.get_blob_to_text(container_name = container,
                                                  blob_name = archive_location)
        self.logger.debug('Retrieved ' + archive_url)
    except:
        self.logger.error('Failed to retrieve text blob {} {}'.format(archive_url, traceback.format_exc()))

    return blob

After running this function and getting the blob object back (which is in my case some HTML content), if I inspect it in Visual Studio 2017, I get the following incomplete blob text, as shown by the ...

enter image description here

My question is: How can I get the full text blob instead of a portion of it? What am I doing wrong?

aBlaze
  • 2,436
  • 2
  • 31
  • 63
  • 1
    is it just because of the debugger ? could you try to save the file and see if it is complete ? – Thomas May 25 '18 at 09:03
  • You were right - it was Visual Studio's Text Visualizer which was not displaying the entire value of the string. Interestingly, in Jay's answer below, where he is using the same VS Text Visualizer, the entire HTML string shows up. – aBlaze May 25 '18 at 16:39
  • Good to here. I am guessing it is st a VS config – Thomas May 26 '18 at 04:28

2 Answers2

4

I can't reproduce your issue on my side. I get the blob content successfully via the code as below :

from azure.storage.blob import (
    BlockBlobService
)

accountName = "***"
accountKey = "***"
containerName = "test1"

blobService = BlockBlobService(account_name=accountName, account_key=accountKey)

blobContent = blobService.get_blob_to_text(containerName,"storage.html")

print(blobContent.content)

And I tried to debug it in the Text Visualizer.It can be fully displayed if I dragged the window properly.

enter image description here

Hope it helps you.

Jay Gong
  • 23,163
  • 2
  • 27
  • 32
  • Thank you so much for taking the time to help! It turns out the VS Text Visualizer was truncating the HTML string. But your VS Text Visualizer doesn't truncate. We must be using different versions of VS and/or there is a bug in my version of VS. – aBlaze May 25 '18 at 16:40
1

It seems that the code was working correctly, but Visual Studio's Text Visualizer was the cause of the truncation, as described in this Stack Overflow answer. I can confirm this because if I print the blob's content to console, then all of the HTML is printed.

It seems that some versions of Visual Studio perform the truncation, while others do not (as seen in Jay's answer where his Visual Studio Text Visualizer shows the entirety of the blob's content; meanwhile in my Text Visualizer, I was only seeing a partial string).

aBlaze
  • 2,436
  • 2
  • 31
  • 63