Azure-sdk-for-python: Container client fails slowly instead of ResourceNotFound

Created on 14 Sep 2020  路  8Comments  路  Source: Azure/azure-sdk-for-python

  • azure-storage-blob
  • 12.3.2
  • Ubuntu 20.04
  • 3.8.2

Describe the bug
I've been advised in #12744 to open a new issue for this behaviour.

I'm trying to use

from azure.storage.blob import ContainerClient

client = ContainerClient("storage1234567", container_name="container-01")
client.get_container_properties()

to check if a container exists. I had expected either an immediate ResourceNotFound or otherwise some unauthorised message - basically anything that would allow me to fail fast. Instead the command runs for about 2 minutes, retrying twice (three times in total, I believe with some backoff) resulting in

azure.core.exceptions.ServiceRequestError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f7bd6ef8bb0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution

I have also tried all the timeout kwargs I can think of, timeout, read_timeout, connection_timeout, socket_timeout (supplied as numeric or tuple) and none make a difference.

Is there a way to short-circuit this and allow me to catch some faster failure?

To Reproduce

from azure.storage.blob import ContainerClient

client = ContainerClient("storage1234567", container_name="container-01")
client.get_container_properties()

Expected behavior
@tasherif-msft advises

Hi @AkhilGNair, interesting issue you've come across, but this is actually an unexpected behavior. The error you're getting implies the request was not sent (you would receive a ResourceNotFound response from the server if the request was sent).

My expectation is that I can quickly catch a failure!

Client Service Attention Storage customer-reported needs-team-attention question

All 8 comments

Hi @AkhilGNair

The error says "Temporary failure in name resolution"
can you try to change the container name to "container01"

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

Hi @AkhilGNair any updates on the issue? is it still persistent even after the container renaming?

Sorry, haven't been able to check this yet - will update tomorrow morning UK time! Thanks

Sorry for the long delay!

When trying

>>> client = ContainerClient("storage1234567", container_name="container01")  # changed from "container-01"
>>> client.get_container_properties()

I get the same error. A very long wait time, followed by

azure.core.exceptions.ServiceRequestError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f5713a79d00>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution

Thanks!

Hi @AkhilGNair,

On a closer look at your example, I noticed you put storage1234567 as your account url, which is incorrect. Your account url for the blob service should look something like: https://<STORAGE_ACC_NAME>.blob.core.windows.net or just <STORAGE_ACC_NAME>.blob.core.windows.net.

So assuming your account name is storage1234567, the account url would be: https://storage1234567.blob.core.windows.net You also have to ensure that you have set your credentials to be able to access that storage account and its resources, i.e, using a connection string or generating a SAS for example.

Here is two good walk-throughs for this: https://docs.microsoft.com/en-us/python/api/overview/azure/storage-blob-readme?view=azure-python and https://docs.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.containerclient?view=azure-python

This would also explain why the request was not sending.

Your issue also made me realize that we need to add an extra check to our account_url validation :)

Let me know if this fixes your issue.

This is great (and makes me feel stupid :wink:) - the validation would be perfect as it was just the URL validation I was missing.

Creds are fine, no issue there - just wanted to catch the unauthorised error.

Thank you!

Was this page helpful?
0 / 5 - 0 ratings