如何使用 Azure 数据工厂服务的 Web Activity 将实体插入到 Azure 存储 table

How to insert an entity into Azure Storage table using Web Activity of Azure Data Factory service

我在存储帐户中有一个 table。我想通过使用来自 link (link (https://docs.microsoft.com/en-us/rest/api/storageservices/insert-entity) 的 Web Activity 将实体插入此 table 来进行测试。 我还尝试在 Web Activity 设置中为我的共享密钥 (https://docs.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key) 创建一个具有以下格式的 header:

Authorization="SharedKey <_AccountName>:<_Signature>"

但动态表达式中似乎没有为 <_Signature> 创建 Hash-based 消息验证码 (HMAC) 的函数。 有人可以给我一些样本或一些提示吗?谢谢

我们提供了在使用数据流时在表达式构建器中使用 sha2 编码的规定。

但是在数据工厂管道中使用网络 activity 时,您将不得不使用变通方法。这是我尝试过的,调用基于powershell的无服务器功能应用程序对签名进行编码。

powershell 中的基本思想:

$ClearString = "String_to_sign"
    $hasher = [System.Security.Cryptography.HashAlgorithm]::Create('sha256')
    $hash = $hasher.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($ClearString))

    $hashString = [System.BitConverter]::ToString($hash)
    $body = $hashString.Replace('-', '').ToLower()

1. 调用函数app:

与 body: JSON 与 String_to_sign

{
  "name": 'pipeline().parameters.StringToSign'
}

2. 将函数应用程序输出 (HMAC) 分配给变量:(稍后使用 base64 进行编码)

@activity('Azure Function1').output.Response

3. 根据您的场景配置 WebActivity:

注意:我使用示例数据进行演示,请根据需要使用此方法进行修改。

使用 base64 函数编码 HMAC 并准备授权 header。

Authorization: @concat('SharedKey kteststoragee:',base64(variables('sha256'))) 

构建授权 header 以下 MS 文档:Table service (Shared Key authorization 使用 Concat 等字符串函数构建最终字符串。