Jul 082014

Man, this was driving me nuts. Using identical code as successful queue/topic receive operations against the Azure Service Bus, I was perplexed to see “no valid sources” as if my broker address was wrong. I checked it repeatedly, and started doubting that I had the wrong broker settings.

In the end, it was the SAS policy key. Azure generates a healthily-long key. This was the first one I got that  had / (slash) and + (plus) characters in the key. As this key is part of the URI Qpid Proton uses to connect to the broker, it needs to be URL-encoded. Simple enough to fix in python:

import urllib
sasPolicyKey = "<your key from Azure with slashes and/or plus signs>"
safeSasPolicyKey = urllib.quote(sasPolicyKey, "")