-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
Is your feature request related to a problem? Please describe.
I noticed a discrepancy in .net asb sdk and python sdk when it comes to parsing the fully_qualified_namespace. Half of my team is developing in .net and we get the namespace url in the following format:
https://<myservicebus>.servicebus.windows.net:443/
i.e. it ends with the port :443/. Connecting to it like:
from azure.identity.aio import DefaultAzureCredential
from azure.servicebus.aio import ServiceBusClient
client = ServiceBusClient(
fully_qualified_namespace="myservicebus.servicebus.windows.net:443/",
credential=DefaultAzureCredential(),
)
rec=client.get_queue_receiver("myqueue")
msgs=await rec.receive_messages(max_wait_time=1)
Results in an error:
azure.servicebus.exceptions.ServiceBusAuthenticationError: Service Bus has encountered an error. Error condition: amqp:client-error.
Whereas connecting without port, i.e.:
client = ServiceBusClient(
fully_qualified_namespace="myservicebus.servicebus.windows.net",
credential=DefaultAzureCredential(),
)
rec=client.get_queue_receiver("myqueue")
msgs=await rec.receive_messages(max_wait_time=1)
Worked as expected. It was not immediately clear to me why, especially because it worked for my .net colleagues.
Describe the solution you'd like
In azure.servicebus._common.utils I'd prefer to see something like:
def parse_namespace_from_uri(uri: str) -> str:
"""Removes the protocol (e.g. http:// or sb://) and port (e.g. :443/) from a URI, such as the FQDN.
:param str uri: The URI to modify.
:return: The URI without the protocol.
:rtype: str
"""
left_slash_pos = uri.find("//")
if left_slash_pos != -1:
uri = uri[left_slash_pos + 2 :]
colon_pos = uri.find(":")
if colon_pos != -1:
uri = uri[colon_pos:]
return uri
Describe alternatives you've considered
Removing port manually works fine.
Additional context
Add any other context or screenshots about the feature request here.