从Azure自动化帐户Powershell上传数据

我有一些代码可以从Azure Monitor中提取kusto查询,我需要将数据上传到Blob存储帐户以进行长期保留。

在测试窗格中运行时,我可以拉出数据并将其显示在azure自动化屏幕中,但不会上传到blob。

我认为错误在这里

    $SearchResult 

    $StorageaccountName = Get-AutomationVariable -Name "accessKey"
    $StorageaccountKey = Get-AutomationVariable -Name "StorageaccName"

    foreach ($sr in $SearchResult){        
$ctx = New-AzureStorageContext -StorageaccountName $StorageaccountName `
         -StorageaccountKey $StorageaccountKey    
$ContainerName = "Data"    
New-AzureStorageContainer -Name $ContainerName -Context $ctx -Permission Blob

$BlobName = "$sr"
Set-AzureStorageBlobContent -Container $ContainerName -Blob $BlobName `
        -Context $ctx

完整的脚本在下面

https://pastebin.com/embed_iframe/RyLJZVKW

基本上,它使用一些存储的变量进行身份验证,然后运行查询以返回下面的结果(直到该部分有效),但是我想将数据上传到Blob。

可以在以下位置找到输出示例:

https://pastebin.com/embed_iframe/fEF6NsnK

如果有一种更好的将kusto查询直接存储到blob存储的方法,我很乐意考虑这一点..谢谢大家:)

yc857622872 回答:从Azure自动化帐户Powershell上传数据

您的200呼叫似乎缺少Set-AzureStorageBlobContent参数。您可能会在作业“错误”流中收到一条抱怨此消息的消息。

假设您要发送存储在-File变量中的数据,则类似的事情应该起作用(未经测试):

$sr
本文链接:https://www.f2er.com/2751898.html

大家都在问