I want to connect to Azure Blob Storage

Certified Associate Developer

Hi ,

I am trying to connect to connect to Azure Blob Storage. I am canonicalizing the auth header but facing an issue somewhere that i cant identify. Can anyone please help on this? Here is the error message : 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    C# code thats working -
    using System;
    using System.Text;
    using System.Security.Cryptography;

    public class HelloWorld
    {
    string signWithAccountKey(string stringToSign, string accountKey)
    {
    var hmacsha = new System.Security.Cryptography.HMACSHA256();
    hmacsha.Key = Convert.FromBase64String(accountKey);
    var signature = hmacsha.ComputeHash(Encoding.UTF8.GetBytes(stringToSign));
    return Convert.ToBase64String(signature);
    }
    public static void Main(string[] args)
    {
    HelloWorld h = new HelloWorld();
    Console.WriteLine (h.signWithAccountKey("GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Thu, 22 Feb 2024 12:51:11 GMT\nx-ms-version:2015-04-05\n/myblobstorage/myContainer/Note.png","Access Key"));
    }
    }

    Appian alternate created for same but not generating same key as C# code

    a!localVariables(

    local!signatureString:"GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Thu, 22 Feb 2024 12:51:11 GMT\nx-ms-version:2015-04-05\n/myblobstorage/myContainer/Note.png",
    local!base64Key: decodebase64string(cons!AS_SHARED_KEY2),
    local!unicodeSign:code(local!signatureString),
    local!hashKey: hmacsha256hash(local!base64Key,local!unicodeSign),
    local!base64EncodedSign:encodebase64string(local!hashKey),
    {
    touniformstring(local!base64EncodedSign)
    }
    )

Reply
  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    C# code thats working -
    using System;
    using System.Text;
    using System.Security.Cryptography;

    public class HelloWorld
    {
    string signWithAccountKey(string stringToSign, string accountKey)
    {
    var hmacsha = new System.Security.Cryptography.HMACSHA256();
    hmacsha.Key = Convert.FromBase64String(accountKey);
    var signature = hmacsha.ComputeHash(Encoding.UTF8.GetBytes(stringToSign));
    return Convert.ToBase64String(signature);
    }
    public static void Main(string[] args)
    {
    HelloWorld h = new HelloWorld();
    Console.WriteLine (h.signWithAccountKey("GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Thu, 22 Feb 2024 12:51:11 GMT\nx-ms-version:2015-04-05\n/myblobstorage/myContainer/Note.png","Access Key"));
    }
    }

    Appian alternate created for same but not generating same key as C# code

    a!localVariables(

    local!signatureString:"GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Thu, 22 Feb 2024 12:51:11 GMT\nx-ms-version:2015-04-05\n/myblobstorage/myContainer/Note.png",
    local!base64Key: decodebase64string(cons!AS_SHARED_KEY2),
    local!unicodeSign:code(local!signatureString),
    local!hashKey: hmacsha256hash(local!base64Key,local!unicodeSign),
    local!base64EncodedSign:encodebase64string(local!hashKey),
    {
    touniformstring(local!base64EncodedSign)
    }
    )

Children
No Data