小编Sam*_*ren的帖子

Powershell中的Azure API SharedKeyLite

我正在尝试在PowerShell中实现SharedKeyLite授权头函数.这是连接到Azure Tables REST API.我遗漏了一些因为我一直收到错误:

服务器无法验证请求.确保正确形成Authorization标头的值,包括签名.

   function GenerateHeader($accountName, $accountKey, $action)
{
    $xmsdate = get-date
    $xmsdate = $xmsdate.ToUniversalTime()
    $xmsdate = $xmsdate.toString('r')
    $newLine = "`n";
    $message = $xmsdate + $newline + "/" + $accountname + "/" + $action;
    $hmacsha = New-Object System.Security.Cryptography.HMACSHA256
    $hmacsha.key = [Convert]::FromBase64String($accesskey)
    $signature = $hmacsha.ComputeHash([Text.Encoding]::UTF8.GetBytes($message))
    $signature = [Convert]::ToBase64String($signature)
    $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
    $headers.Add("x-ms-version", "2014-02-14")
    $headers.Add("x-ms-date", $xmsdate)
    $headers.Add("Authorization", "SharedKeyLite " + $accountName + ":" + $signature)

    return $headers
}
Run Code Online (Sandbox Code Playgroud)

更新:这是调用此函数的代码.$ action变量设置为URI字符串.

$uriString = "https://$StorageAccountName.table.core.windows.net/Tables"

$headers = GenerateHeader $StorageAccountName $StorageAccountKey "Tables"

Invoke-RestMethod …
Run Code Online (Sandbox Code Playgroud)

powershell azure azure-table-storage

13
推荐指数
1
解决办法
614
查看次数

SQL Server xQuery 返回 NULL 而不是空

因此,在此示例中,我尝试为 element2 和 element3 返回 NULL 而不是空 nvarchar。我似乎无法在任何地方找到这个问题的答案,或者是否有可能。我知道我可以使用 Case/When 的 nullif 检查 .exists() ,但为了性能我宁愿不进行该检查。

WqlEventQuery 查询 = new WqlEventQuery();
        query.EventClassName = "__InstanceCreationEvent";
        query.Condition = "TargetInstance ISA 'Win32_NTLogEvent'";
        query.GroupWithinInterval = new TimeSpan(0, 0, 10);
        System.Collections.Specialized.StringCollection 集合 =
            新的 System.Collections.Specialized.StringCollection();
        Collection.Add("TargetInstance.SourceName");
        query.GroupByPropertyList = 集合;
        query.HavingCondition = "NumberOfEvents > 25";

.net wmi xquery

3
推荐指数
1
解决办法
2109
查看次数

标签 统计

.net ×1

azure ×1

azure-table-storage ×1

powershell ×1

wmi ×1

xquery ×1