Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure-storage-queue can't connect to Azurite if url doesn't start with 127.0.0.1 or localhost #19202

Closed
JoaquinLeonArg opened this issue Jun 10, 2021 · 7 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)

Comments

@JoaquinLeonArg
Copy link

  • Package Name: azure-storage-queue
  • Package Version: 12.1.6
  • Operating System: Ubuntu 21.04
  • Python Version: 3.8

Describe the bug
When connecting to a local Azurite instance (through 127.0.0.1 or localhost), everything works. However, if the azurite url does not start with 127.0.0.1 nor localhost (for example, if trying to connect between Docker containers using the container name) it fails with a ValueError("Unable to determine account name for shared key credential.").

I've found that in the azure/storage/queue/_shared/base_client.py, there is a special case only for urls starting with 127.0.0.1 or localhost, so I suspect that might be causing the issue:

if not self.account_name and parsed_url.netloc.startswith("localhost") or parsed_url.netloc.startswith("127.0.0.1"):
        self.account_name = parsed_url.path.strip("/")

To Reproduce
Steps to reproduce the behavior:

Try to connect to an Azurite instance with the following code:

queue_client = QueueClient.from_queue_url(
        f'http://azurite:10001/devstoreaccount1/my_queue',
        'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=='
    )

Expected behavior
The connection should be created and I should be able to connect to the queue.

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jun 10, 2021
@yunhaoling yunhaoling added Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files) labels Jun 10, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Jun 10, 2021
@yunhaoling
Copy link
Contributor

hey @JoaquinLeonArg , thanks for your feedback, we'll investigate ASAP.
adding @xiafu-msft to take a look.

@amishra-dev
Copy link

@tasherif-msft / @xiafu-msft fyi

@tasherif-msft tasherif-msft self-assigned this Jun 14, 2021
@tasherif-msft
Copy link
Contributor

Hi @JoaquinLeonArg, thank you for reporting this, I will investigate this issue and get back to you!

@lmazuel lmazuel added the Service Attention Workflow: This issue is responsible by Azure service team. label Aug 5, 2021
@ghost
Copy link

ghost commented Aug 5, 2021

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

Issue Details
  • Package Name: azure-storage-queue
  • Package Version: 12.1.6
  • Operating System: Ubuntu 21.04
  • Python Version: 3.8

Describe the bug
When connecting to a local Azurite instance (through 127.0.0.1 or localhost), everything works. However, if the azurite url does not start with 127.0.0.1 nor localhost (for example, if trying to connect between Docker containers using the container name) it fails with a ValueError("Unable to determine account name for shared key credential.").

I've found that in the azure/storage/queue/_shared/base_client.py, there is a special case only for urls starting with 127.0.0.1 or localhost, so I suspect that might be causing the issue:

if not self.account_name and parsed_url.netloc.startswith("localhost") or parsed_url.netloc.startswith("127.0.0.1"):
        self.account_name = parsed_url.path.strip("/")

To Reproduce
Steps to reproduce the behavior:

Try to connect to an Azurite instance with the following code:

queue_client = QueueClient.from_queue_url(
        f'http://azurite:10001/devstoreaccount1/my_queue',
        'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=='
    )

Expected behavior
The connection should be created and I should be able to connect to the queue.

Author: JoaquinLeonArg
Assignees: xiafu-msft, tasherif-msft
Labels:

Storage, question, Service Attention, Client, customer-reported

Milestone: -

@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Aug 5, 2021
@amishra-dev amishra-dev added feature-request This issue requires a new behavior in the product in order be resolved. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 3, 2021
@navba-MSFT
Copy link
Contributor

@JoaquinLeonArg Apologies for the late reply. We will update this thread once we have more details on this.

@tasherif-msft @xiafu-msft Could you please provide an update on this request ? Awaiting your reply.

@vincenttran-msft
Copy link
Member

vincenttran-msft commented Jun 16, 2022

Hi @JoaquinLeonArg Joaquín, I just wanted to touch base with you to see if this has not been resolved yet? I do see that the issue may lie our parsing so that may require further investigation and we will get back to you if there are any updates. In the meantime, perhaps this work-around would help to unblock your workflow:

from_queue_url accepts a credential parameter as seen here. With that being said, you can alternatively provide the credentials directly in a dictionary format.

The format of this dictionary should be the following:
cred_dict = {"account_name": <ACCOUNT_NAME>, "account_key": <ACCOUNT_KEY>}
Then ensure you are passing this in as the credential= param for your call to the from_queue_url API.

Please give that a try if your problem is still persisting and hopefully that should do the trick!
Thanks!

@vincenttran-msft vincenttran-msft added needs-author-feedback Workflow: More information is needed from author to address the issue. and removed feature-request This issue requires a new behavior in the product in order be resolved. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Jun 16, 2022
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-python that referenced this issue Jun 23, 2022
Mitryakh/network 2022 01 01 (Azure#19412)

* Adds base for updating Microsoft.Network from version stable/2021-08-01 to version 2022-01-01

* Updates readme

* Updates API version in new specs and examples

* Updated Explicit proxy settings by adding one boolean field to it (Azure#19011)

* API for provider port (Azure#19041)

* Update readme.md

* Create expressRouteProviderPort.json

* Create expressRouteProviderPortList.json

* Create expressRouteProviderPort.json

* Update custom-words.txt

* Update expressRouteProviderPort.json

* Update expressRouteProviderPortList.json

* Update expressRouteProviderPort.json

* Add WAF match variable operators (Azure#18925)

### webapplicationfirewall.json
* Add GreaterThanOrEquals operator and Any operator to custom rule
  match conditions in WAF policy spec

* Add VirtualHub Router autoscale configuration (Azure#19131)

Co-authored-by: Andrii Kalinichenko <[email protected]>

* Adding rule priority to Tls Proxy routing rule object model (Azure#19135)

Co-authored-by: Vinay Mundada <[email protected]>

* swagger changes for new ssl policies (Azure#19183)

* Update Swagger Spec for VMSS Packet Capture (Azure#19202)

* Update Swagger Spec for VMSS Packet Capture

* Remove extra line

* Update Swagger spec for Connection Monitor VMSS (Azure#19203)

* Adding new endpoint in ConnectionMonitor

* Changing ConnectionMonitor endpoints order

* Add flushConnection to NSG (Azure#19085)

* Merge NetworkManger into 2022-01-01 (Azure#19169)

* Merge NetworkManger into 2022-01-01

* Remove EffectiveVnet APIs

* Remove SecurityUser Resource

* update readme

* Fix as comments

* fix as comments

* remove network group type

* Add new parameter noInternetAdvertise to CustomIPPrefix (Azure#19340)

* fix

* fix

Co-authored-by: Weiheng Li <[email protected]>

* Route Server Integration feature swagger changes (Azure#19215)

* Route Server Integration feature swagger changes

* prettier run changes

* updating api version in examples file

* fixing test errors

* fixing test errors

* fixing modelvalidation errors

* fixing test errors

* fixing modelvalidation errors

* changes based on review comments

* fixing lintdiff failure

* updating examples

* update wrong enum value for customipprefix (Azure#19382)

* fix

* fix

* fix

Co-authored-by: Weiheng Li <[email protected]>

* Updated ExplicitProxySettings to ExplicitProxy on Firewall Policy ver2022-01-01 (Azure#19299)

Co-authored-by: Gizachew Eshetie <[email protected]>

* Add resource type (Azure#19434)

Co-authored-by: Andrii Kalinichenko <[email protected]>

* Fix prettier errors (Azure#19462)

Co-authored-by: Andrii Kalinichenko <[email protected]>

Co-authored-by: uditmisra52 <[email protected]>
Co-authored-by: jashsing-mic <[email protected]>
Co-authored-by: Anurag Kishore <[email protected]>
Co-authored-by: AndriiKalinichenko <[email protected]>
Co-authored-by: Andrii Kalinichenko <[email protected]>
Co-authored-by: Vinay Jayant Mundada <[email protected]>
Co-authored-by: Vinay Mundada <[email protected]>
Co-authored-by: kaushik-ms <[email protected]>
Co-authored-by: snagpal99 <[email protected]>
Co-authored-by: kumaam <[email protected]>
Co-authored-by: Satya-anshu <[email protected]>
Co-authored-by: yanfa317 <[email protected]>
Co-authored-by: Weiheng Li <[email protected]>
Co-authored-by: Weiheng Li <[email protected]>
Co-authored-by: Anchal Kapoor <[email protected]>
Co-authored-by: Gizachew-Eshetie <[email protected]>
Co-authored-by: Gizachew Eshetie <[email protected]>
@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Jun 25, 2022
@ghost
Copy link

ghost commented Jun 25, 2022

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. Service Attention Workflow: This issue is responsible by Azure service team. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

No branches or pull requests

8 participants