我在設置從Python腳本到Azure服務總線的連接時遇到問題。 C#中的類似代碼(在Windows上)運行良好。Python和Azure服務總線
from azure.servicebus import *
AZURE_SERVICEBUS_NAMESPACE='blablabla.servicebus.windows.net'
AZURE_SERVICEBUS_ISSUER='RootManageSharedAccessKey'
AZURE_SERVICEBUS_ACCESS_KEY='sdkfjlkewjrlwerjlewrjlewrjfjflsdkfjew3='
bus_service = ServiceBusService(service_namespace=AZURE_SERVICEBUS_NAMESPACE, account_key=AZURE_SERVICEBUS_ACCESS_KEY, issuer=AZURE_SERVICEBUS_ISSUER)
bus_service.create_queue('taskqueue')
這將導致以下的輸出:
Traceback (most recent call last): File "createqueue.py", line 9, in bus_service.create_queue('taskqueue') File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py", line 143, in create_queue request.headers = self._update_service_bus_header(request) File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py", line 860, in _update_service_bus_header ('Authorization', self._sign_service_bus_request(request))) File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py", line 868, in _sign_service_bus_request self._get_token(request.host, request.path) + '"' File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py", line 908, in _get_token resp = self._httpclient.perform_request(request) File "/usr/local/lib/python2.7/dist-packages/azure/http/httpclient.py", line 191, in perform_request self.send_request_headers(connection, request.headers) File "/usr/local/lib/python2.7/dist-packages/azure/http/httpclient.py", line 170, in send_request_headers connection.endheaders() File "/usr/lib/python2.7/httplib.py", line 958, in endheaders self._send_output(message_body) File "/usr/lib/python2.7/httplib.py", line 818, in _send_output self.send(msg) File "/usr/lib/python2.7/httplib.py", line 780, in send self.connect() File "/usr/lib/python2.7/httplib.py", line 1161, in connect self.timeout, self.source_address) File "/usr/lib/python2.7/socket.py", line 553, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): socket.gaierror: [Errno -2] Name or service not known
這是怎麼回事錯在這裏?
感謝
您正在使用哪個版本的Python SDK,以及您何時創建了SB命名空間? – BrentDaCodeMonkey 2014-08-27 15:02:32
好問題:不知道,因爲我剛剛2天前就拉起了pip軟件包。我還用Windows上的Python進行了測試,SDK使用WebInstaller從MSDN中提取。同樣的結果。奇怪我有一個工作腳本創建一個blob存儲容器。我還測試了一個預先配置好的隊列,並且只寫了一條消息。這也會導致相同的錯誤行爲。 – mvhoorn 2014-08-29 05:55:29
我有同樣的問題,沒有解決方案。不是從Windows機器工作,也不是使用Python的Linux機器,而是與.NET一起工作。 – vvucetic 2014-08-29 14:15:55