I'm trying to make a script that creates automatic partions for SSAS via Powershell Runbook, but whenever I try to read in the xmla file i get the following error:
My code that calls this is as followed:
$StorageAccount = Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName
$blob = Get-AzureStorageBlob -Context $StorageAccount.Context -Container "Database name" -Blob "CreateNewPartition.xmla"
$file = $blob.ICloudBlob.DownloadText()
Invoke-ASCmd `
-Database $AnalysisServiceDatabase `
-InputFile $file `
-server $AnalysisServiceServer
When using the following code:
$memStream = New-Object System.IO.MemoryStream
$blob.ICloudBlob.DownloadToStream($memStream)
$readStream = New-Object System.IO.StreamReader($memStream, [System.Text.Encoding]::Unicode)
$memStream.Position = 0
$file = ($readStream.ReadToEnd() -replace "`0",'' | ConvertFrom-Json)
And when trying this code:
$byteArray = New-Object Byte[] $blob.Length
$file = $blob.ICloudBlob.DownloadToByteArray($byteArray, 0)