Public/Azure/Get-WELogAnalyticsSignature.ps1
Function Get-WELogAnalyticsSignature { [cmdletbinding()] Param ( $ALWorkspaceID, $WorkspacePrimaryKey, $date, $contentLength, $method, $contentType, $resource ) $xHeaders = "x-ms-date:" + $date $stringToHash = $method + "`n" + $contentLength + "`n" + $contentType + "`n" + $xHeaders + "`n" + $resource $bytesToHash = [Text.Encoding]::UTF8.GetBytes($stringToHash) $keyBytes = [Convert]::FromBase64String($WorkspacePrimaryKey) $sha256 = New-Object System.Security.Cryptography.HMACSHA256 $sha256.Key = $keyBytes $calculatedHash = $sha256.ComputeHash($bytesToHash) $encodedHash = [Convert]::ToBase64String($calculatedHash) $authorization = 'SharedKey {0}:{1}' -f $ALWorkspaceID,$encodedHash return $authorization } |