Posting on behalf of @effortphydr via Twitter:
I'm generating a SAS key by ruby. It generates some token, which seems correct but wrong. When I use this token, it returns '404 No value' Could someone help me to figure out what's wrong with the code?
Thank you in advance :)
require 'azure'
require 'net/http'
require 'json'
def MakeSASToken(url, key_name, access_key, lifetime)
target_uri = CGI.escape(url.downcase).gsub('+', '%20').downcase
expires =
Time.now.to _i + lifetime
to_sign = "#{target_uri}\n#{expires}"
signature = CGI.escape(Base64.strict_encode64( Digest::HMAC.digest(to_sign, access_key, Digest::SHA256)))
return "SharedAccessSignature sr=#{target_uri}&sig=#{signature}&se=#{expires}&skn=#{key_name}"
end
DefaultAccessKey = 'RootManageSharedAccessKey'
NameSpace = '{mynamespace}'
Putrequest = "//{mynamespace}.servicebus.windows.net/{event_hub}/publishers/{publisher_name}"
KeyValue='{key_value}'
puts "Creating request for #{Putrequest}"
tok = MakeSASToken("#{Putrequest}", DefaultAccessKey, KeyValue, 36000)
puts tok
Thank you,
@AzureSupport