modules/mu/providers/azure.rb in cloud-mu-3.5.0 vs modules/mu/providers/azure.rb in cloud-mu-3.5.1

- old
+ new

@@ -563,16 +563,16 @@ def self.get_metadata(svc = "instance", api_version = "2017-08-01", args: {}, debug: false) loglevel = debug ? MU::NOTICE : MU::DEBUG return @@metadata if svc == "instance" and @@metadata base_url = "http://169.254.169.254/metadata/#{svc}" args["api-version"] = api_version - arg_str = args.keys.map { |k| k.to_s+"="+args[k].to_s }.join("&") + arg_str = args.keys.sort.map { |k| k.to_s+"="+CGI.escape(args[k].to_s) }.join("&") begin Timeout.timeout(2) do - resp = JSON.parse(URI.open("#{base_url}/?#{arg_str}","Metadata"=>"true").read) - MU.log "curl -H Metadata:true "+"#{base_url}/?#{arg_str}", loglevel, details: resp + resp = JSON.parse(URI.open("#{base_url}?#{arg_str}","Metadata"=>"true").read) + MU.log "curl -H Metadata:true "+"#{base_url}?#{arg_str}", loglevel, details: resp if svc != "instance" return resp else @@metadata = resp end @@ -595,12 +595,12 @@ # @return [Hash] def self.getSDKOptions(credentials = nil) cfg = credConfig(credentials) if cfg and MU::Cloud::Azure.hosted? - token = MU::Cloud::Azure.get_metadata("identity/oauth2/token", "2018-02-01", args: { "resource"=>"https://management.azure.com/" }) + token = MU::Cloud::Azure.get_metadata("identity/oauth2/token", "2020-09-01", args: { "resource"=>"https://management.azure.com/" }) if !token - MU::Cloud::Azure.get_metadata("identity/oauth2/token", "2018-02-01", args: { "resource"=>"https://management.azure.com/" }, debug: true) + MU::Cloud::Azure.get_metadata("identity/oauth2/token", "2020-09-01", args: { "resource"=>"https://management.azure.com/" }, debug: true) raise MuError, "Failed to get machine oauth token" end machine = MU::Cloud::Azure.get_metadata return { credentials: MsRest::TokenCredentials.new(token["access_token"]),