![](/img/trans.png)
[英]Whitelist Azure Automation account in Azure Storage to read zipped module from blob and upload in azure automation module
[英]Upload data from Azure Automation Account 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 存儲,我很樂意考慮......謝謝大家:)
您的Set-AzureStorageBlobContent
調用似乎缺少-File
參數。 您可能會在作業錯誤流中收到一條抱怨此問題的消息。
假設你想發送存儲在$sr
變量中的數據,這樣的事情應該可以工作(未經測試):
$tempFile = New-TemporaryFile
$sr | Out-File -FilePath $tempFile.FullName
Set-AzureStorageBlobContent ... -File $tempFile.FullName
Remove-Item $tempFile
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.