I’m running a PowerShell script in Azure function (Timer Trigger) which will fetch PowerBI workspace data from Azure and it will store to Blob storage.
I want the output data of the Azure function to be stored in csv format in Blob.
Currently storing as .json
here is my query,
# Input bindings are passed in via param block.
param($Timer)
# Get the current universal time in the default string format.
$currentUTCtime = (Get-Date).ToUniversalTime()
# The 'IsPastDue' property is 'true' when the current function invocation is later than scheduled.
if ($Timer.IsPastDue) {
Write-Host "PowerShell timer is running late!"
}
# Write an information log with the current time.
Write-Host "PowerShell timer trigger function ran! TIME: $currentUTCtime"
$secret="********"
$tenantId="********"
$appId="********"
$password= ConvertTo-SecureString $secret -AsPlainText -Force
$credential= New-Object System.Management.Automation.PSCredential ($appId, $password)
#Connecting to PowerBI
Connect-PowerBIServiceAccount -ServicePrincipal -Tenant $tenantId -Credential $credential
#Getting PowerBI Workspace data
$body = Get-PowerBIWorkspace -Scope Organization
#output to the blob file
Push-OutputBinding -Name outputBlob -Value $body
2
Answers
You can use convert from JSON to CSV to achieve this.
Workaround follows
I posted an example of how to do this using the Az module commands as you are not able to modify the properties of the blob using the output binding at present and all files get saved as
application/octet-stream
by default.Output Azure Function powershell value to azure storage account